private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); return true; } }); }
private void setupTabs() { tlUserProfileTabs.addTab(tlUserProfileTabs.newTab().setIcon(R.drawable.ic_grid_on_white)); tlUserProfileTabs.addTab(tlUserProfileTabs.newTab().setIcon(R.drawable.ic_list_white)); tlUserProfileTabs.addTab(tlUserProfileTabs.newTab().setIcon(R.drawable.ic_place_white)); tlUserProfileTabs.addTab(tlUserProfileTabs.newTab().setIcon(R.drawable.ic_label_white)); }
private void showSnackbar() { Snackbar snackbar = Snackbar.make(view, text, duration); if (buttonText != null && onButtonClickListener != null) { snackbar.setAction(buttonText, onButtonClickListener); } if (snackbarCallback != null) { snackbar.setCallback(snackbarCallback); } snackbar.show(); }
private void initView() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); detailPlayer = (LandLayoutVideo) findViewById(R.id.detail_player); root = (CoordinatorLayout) findViewById(R.id.root_layout); setSupportActionBar(toolbar); toolBarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout); toolBarLayout.setTitle(getTitle()); fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { detailPlayer.startPlayLogic(); root.removeView(fab); } }); appBar = (AppBarLayout) findViewById(R.id.app_bar); appBar.addOnOffsetChangedListener(appBarStateChangeListener); }
private void setupTabLayout(TabLayout tabLayout) { tabLayout.setTabMode(TabLayout.MODE_FIXED); tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); tabLayout.setupWithViewPager(mViewPager); }
public void updateTabs() { slidingTabsLayout.setupWithViewPager(pager); }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { child.setVisibility(View.INVISIBLE); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { child.show(); } } }
@Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { listener.onCoordinatorUpdate( verticalOffset >= 0, /*refreshLayout.isEnableLoadMore() && */ (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0); } });
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mAppBarLayout.setBackgroundResource(colorPrimary); mToolbarLayout.setContentScrimResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); mActionButton.setBackgroundColor(ContextCompat.getColor(this, colorPrimaryDark)); mActionButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, colorPrimaryDark))); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }
private float getClosingRadius() { final int buttonRadius = closeOverlayButton.getWidth() / 2; // 20% wider than the button itself return buttonRadius * 1.2f; }
@Override public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) { super.onStopNestedScroll(coordinatorLayout, child, target); }
@Override public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) { return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY); }
@Override public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) { return super.onSaveInstanceState(parent, child); }
@Override public void onPageSelected(int position) { navigation.setSelectedItemId(TabFragment.values()[position].menuId); } });
@Override public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) { super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); }
@Override public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) { appBar.setTranslationY(offset); toolbar.setTranslationY(-offset); } // @Override
private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(final MenuItem menuItem) { updatePosition(menuItem); return true; } }); }
private void setThemeColor(int colorPrimary, int colorPrimaryDark) { mToolbar.setBackgroundResource(colorPrimary); mAppBarLayout.setBackgroundResource(colorPrimary); mToolbarLayout.setContentScrimResource(colorPrimary); mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); mActionButton.setBackgroundColor(ContextCompat.getColor(this, colorPrimaryDark)); mActionButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, colorPrimaryDark))); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); } }