List of usage examples for android.widget ScrollView getParent
public final ViewParent getParent()
From source file:org.weyoung.xianbicycle.BaseActivity.java
private void setupNavDrawer() { // What nav drawer item should be selected? int selfItem = getCurrentNavDrawerItem(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (mDrawerLayout == null) { return;//from ww w.j ava 2s .c o m } mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); ScrollView navDrawer = (ScrollView) mDrawerLayout.findViewById(R.id.navdrawer); if (selfItem == NAVDRAWER_ITEM_INVALID) { // do not show a nav drawer if (navDrawer != null) { ((ViewGroup) navDrawer.getParent()).removeView(navDrawer); } mDrawerLayout = null; return; } if (mActionBarToolbar != null) { mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer); mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDrawerLayout.openDrawer(Gravity.START); } }); } mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View drawerView) { // run deferred action, if we have one if (mDeferredOnDrawerClosedRunnable != null) { mDeferredOnDrawerClosedRunnable.run(); mDeferredOnDrawerClosedRunnable = null; } onNavDrawerStateChanged(false, false); } @Override public void onDrawerOpened(View drawerView) { if (showcaseView != null && showcaseView.isShowing()) { showcaseView.hide(); } onNavDrawerStateChanged(true, false); } @Override public void onDrawerStateChanged(int newState) { onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { onNavDrawerSlide(slideOffset); } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); // populate the nav drawer with the correct items populateNavDrawer(); goToNavDrawerItem(NAVDRAWER_ITEM_DEFAULT); }
From source file:com.davisosa.structura.activities.base.BaseActivity.java
/** * Sets up the navigation drawer as appropriate. *//* ww w.j a v a2s.c o m*/ private void setupNavigationDrawer() { // Selected navigation drawer item int selfItem = getSelfDrawerItem(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (mDrawerLayout == null) { return; } mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark)); ScrollView drawer = (ScrollView) mDrawerLayout.findViewById(R.id.drawer); if (selfItem == DRAWER_ITEM_INVALID) { // Don't show a navigation drawer. if (drawer != null) { ((ViewGroup) drawer.getParent()).removeView(drawer); } mDrawerLayout = null; return; } /* ActionBarDrawerToggle ties together the the proper interactions * between the navigation drawer and the action bar app icon. */ mDrawerToggle = setupDrawerToggle(mActionBarToolbar, mDrawerLayout, new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View drawerView) { invalidateOptionsMenu(); // Calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); // Calls onPrepareOptionsMenu() } @Override public void onDrawerStateChanged(int newState) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); // Populate the navigation drawer with the correct items. populateDrawer(); mDrawerToggle.syncState(); // First run of the app starts with the navigation drawer open. if (!PrefUtils.isWelcomeDone(this)) { PrefUtils.markWelcomeDone(this); mDrawerLayout.openDrawer(Gravity.START); } }