Search in sources :

Example 6 with LayoutParams

use of android.support.v4.widget.DrawerLayout.LayoutParams in project qualitymatters by artem-zinnatullin.

the class MainActivityViewModifier method modify.

@NonNull
@Override
public <T extends View> T modify(@NonNull T view) {
    // Basically, what we do here is adding a Developer Setting Fragment to a DrawerLayout!
    DrawerLayout drawerLayout = (DrawerLayout) view.findViewById(R.id.main_drawer_layout);
    DrawerLayout.LayoutParams layoutParams = new DrawerLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    layoutParams.gravity = Gravity.END;
    drawerLayout.addView(LayoutInflater.from(view.getContext()).inflate(R.layout.developer_settings_view, drawerLayout, false), layoutParams);
    return view;
}
Also used : DrawerLayout(android.support.v4.widget.DrawerLayout) NonNull(android.support.annotation.NonNull)

Example 7 with LayoutParams

use of android.support.v4.widget.DrawerLayout.LayoutParams in project smooth-app-bar-layout by henrytao-me.

the class SmoothAppBarLayout method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    int i = 0;
    for (int z = this.getChildCount(); i < z; ++i) {
        View child = this.getChildAt(i);
        LayoutParams childLp = (LayoutParams) child.getLayoutParams();
        Interpolator interpolator = childLp.getScrollInterpolator();
        if (interpolator != null) {
            mHaveChildWithInterpolator = true;
            break;
        }
    }
}
Also used : Interpolator(android.view.animation.Interpolator) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 8 with LayoutParams

use of android.support.v4.widget.DrawerLayout.LayoutParams in project RxBinding by JakeWharton.

the class RxSwipeRefreshLayoutTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    swipeRefreshLayout = new SwipeRefreshLayout(this);
    swipeRefreshLayout.setId(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
                handler.removeCallbacks(stopRefreshing);
                handler.postDelayed(stopRefreshing, 300);
            }
            return false;
        }
    });
    ScrollView scrollView = new ScrollView(this);
    LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
    swipeRefreshLayout.addView(scrollView, scrollParams);
    FrameLayout emptyView = new FrameLayout(this);
    LayoutParams emptyParams = new LayoutParams(MATCH_PARENT, 100000);
    scrollView.addView(emptyView, emptyParams);
    setContentView(swipeRefreshLayout);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ScrollView(android.widget.ScrollView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 9 with LayoutParams

use of android.support.v4.widget.DrawerLayout.LayoutParams in project Lightning-Browser by anthonycr.

the class BrowserActivity method initialize.

private synchronized void initialize(Bundle savedInstanceState) {
    initializeToolbarHeight(getResources().getConfiguration());
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    //TODO make sure dark theme flag gets set correctly
    mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
    mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
    mDisabledIconColor = mDarkTheme ? ContextCompat.getColor(this, R.color.icon_dark_theme_disabled) : ContextCompat.getColor(this, R.color.icon_light_theme_disabled);
    mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
    mSwapBookmarksAndTabs = mPreferences.getBookmarksAndTabsSwapped();
    // initialize background ColorDrawable
    int primaryColor = ThemeUtils.getPrimaryColor(this);
    mBackground.setColor(primaryColor);
    // Drawer stutters otherwise
    mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerLayout.addDrawerListener(new DrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            if (newState == DrawerLayout.STATE_DRAGGING) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            } else if (newState == DrawerLayout.STATE_IDLE) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) {
        getWindow().setStatusBarColor(Color.BLACK);
    }
    setNavigationDrawerWidth();
    mDrawerLayout.addDrawerListener(new DrawerLocker());
    mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
    final FragmentManager fragmentManager = getSupportFragmentManager();
    TabsFragment tabsFragment = (TabsFragment) fragmentManager.findFragmentByTag(TAG_TABS_FRAGMENT);
    BookmarksFragment bookmarksFragment = (BookmarksFragment) fragmentManager.findFragmentByTag(TAG_BOOKMARK_FRAGMENT);
    if (tabsFragment != null) {
        fragmentManager.beginTransaction().remove(tabsFragment).commit();
    }
    tabsFragment = TabsFragment.createTabsFragment(isIncognito(), mShowTabsInDrawer);
    mTabsView = tabsFragment;
    if (bookmarksFragment != null) {
        fragmentManager.beginTransaction().remove(bookmarksFragment).commit();
    }
    bookmarksFragment = BookmarksFragment.createFragment(isIncognito());
    mBookmarksView = bookmarksFragment;
    fragmentManager.executePendingTransactions();
    fragmentManager.beginTransaction().replace(getTabsFragmentViewId(), tabsFragment, TAG_TABS_FRAGMENT).replace(getBookmarksFragmentViewId(), bookmarksFragment, TAG_BOOKMARK_FRAGMENT).commit();
    if (mShowTabsInDrawer) {
        mToolbarLayout.removeView(findViewById(R.id.tabs_toolbar_container));
    }
    Preconditions.checkNonNull(actionBar);
    // set display options of the ActionBar
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.toolbar_content);
    View customView = actionBar.getCustomView();
    LayoutParams lp = customView.getLayoutParams();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    customView.setLayoutParams(lp);
    mArrowImage = (ImageView) customView.findViewById(R.id.arrow);
    FrameLayout arrowButton = (FrameLayout) customView.findViewById(R.id.arrow_button);
    if (mShowTabsInDrawer) {
        if (mArrowImage.getWidth() <= 0) {
            mArrowImage.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        }
        updateTabNumber(0);
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getTabDrawer());
            }
        });
    } else {
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, getTabDrawer());
            }
        });
        mArrowImage.setImageResource(R.drawable.ic_action_home);
        mArrowImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
    }
    // Post drawer locking in case the activity is being recreated
    Handlers.MAIN.post(new Runnable() {

        @Override
        public void run() {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getBookmarkDrawer());
        }
    });
    arrowButton.setOnClickListener(this);
    // create the search EditText in the ToolBar
    mSearch = (SearchView) customView.findViewById(R.id.search);
    mSearchBackground = customView.findViewById(R.id.search_container);
    // initialize search background color
    mSearchBackground.getBackground().setColorFilter(getSearchBarColor(primaryColor, primaryColor), PorterDuff.Mode.SRC_IN);
    mSearch.setHintTextColor(ThemeUtils.getThemedTextHintColor(mDarkTheme));
    mSearch.setTextColor(mDarkTheme ? Color.WHITE : Color.BLACK);
    mUntitledTitle = getString(R.string.untitled);
    mBackgroundColor = ThemeUtils.getPrimaryColor(this);
    mDeleteIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    mRefreshIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_refresh, mDarkTheme);
    mClearIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    int iconBounds = Utils.dpToPx(24);
    mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
    mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
    mClearIcon.setBounds(0, 0, iconBounds, iconBounds);
    mIcon = mRefreshIcon;
    SearchListenerClass search = new SearchListenerClass();
    mSearch.setCompoundDrawablePadding(Utils.dpToPx(3));
    mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
    mSearch.setOnKeyListener(search);
    mSearch.setOnFocusChangeListener(search);
    mSearch.setOnEditorActionListener(search);
    mSearch.setOnTouchListener(search);
    mSearch.setOnPreFocusListener(search);
    initializeSearchSuggestions(mSearch);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
    if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        //noinspection deprecation
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    }
    @SuppressWarnings("VariableNotUsedInsideIf") Intent intent = savedInstanceState == null ? getIntent() : null;
    boolean launchedFromHistory = intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
    if (isPanicTrigger(intent)) {
        setIntent(null);
        panicClean();
    } else {
        if (launchedFromHistory) {
            intent = null;
        }
        mPresenter.setupTabs(intent);
        setIntent(null);
        mProxyUtils.checkForProxy(this);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TabsFragment(acr.browser.lightning.fragment.TabsFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) BookmarksView(acr.browser.lightning.browser.BookmarksView) BrowserView(acr.browser.lightning.browser.BrowserView) SearchView(acr.browser.lightning.view.SearchView) AutoCompleteTextView(android.widget.AutoCompleteTextView) LightningView(acr.browser.lightning.view.LightningView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) VideoView(android.widget.VideoView) TabsView(acr.browser.lightning.browser.TabsView) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener) FragmentManager(android.support.v4.app.FragmentManager) BookmarksFragment(acr.browser.lightning.fragment.BookmarksFragment) FrameLayout(android.widget.FrameLayout) ActionBar(android.support.v7.app.ActionBar)

Example 10 with LayoutParams

use of android.support.v4.widget.DrawerLayout.LayoutParams in project bdcodehelper by boredream.

the class IndicatorRadioGroup method setViewPager.

public void setViewPager(ViewPager vp, final int count) {
    if (vp == null || vp.getAdapter() == null) {
        return;
    }
    if (count <= 1) {
        setVisibility(View.GONE);
        return;
    }
    setVisibility(View.VISIBLE);
    vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            if (getChildCount() > 1) {
                View child = getChildAt(position % count);
                if (child != null && child instanceof RadioButton) {
                    ((RadioButton) child).setChecked(true);
                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    removeAllViews();
    for (int i = 0; i < count; i++) {
        RadioButton rb = new RadioButton(getContext());
        LayoutParams params = new LayoutParams(DisplayUtils.dp2px(getContext(), 6), DisplayUtils.dp2px(getContext(), 6));
        if (i > 0) {
            params.setMargins(DisplayUtils.dp2px(getContext(), 10), 0, 0, 0);
        }
        rb.setLayoutParams(params);
        rb.setButtonDrawable(new ColorDrawable());
        rb.setBackgroundResource(indicatorRes);
        rb.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // do nothing
                return true;
            }
        });
        addView(rb);
    }
    ((RadioButton) getChildAt(0)).setChecked(true);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) RadioButton(android.widget.RadioButton) ViewPager(android.support.v4.view.ViewPager) View(android.view.View) MotionEvent(android.view.MotionEvent)

Aggregations

View (android.view.View)11 FrameLayout (android.widget.FrameLayout)5 TextView (android.widget.TextView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 LayoutParams (android.view.ViewGroup.LayoutParams)4 EditText (android.widget.EditText)4 Paint (android.graphics.Paint)3 ViewPager (android.support.v4.view.ViewPager)3 DrawerLayout (android.support.v4.widget.DrawerLayout)3 MotionEvent (android.view.MotionEvent)3 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 Intent (android.content.Intent)2 Rect (android.graphics.Rect)2 Handler (android.os.Handler)2 Parcelable (android.os.Parcelable)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 FragmentManager (android.support.v4.app.FragmentManager)2 AbsSavedState (android.support.v4.view.AbsSavedState)2 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)2