/** * Synchronize the state of the drawer indicator/affordance with the linked DrawerLayout. * * <p>This should be called from your <code>Activity</code>'s {@link * Activity#onPostCreate(android.os.Bundle) onPostCreate} method to synchronize after the * DrawerLayout's instance state has been restored, and any other time when the state may have * diverged in such a way that the ActionBarDrawerToggle was not notified. (For example, if you * stop forwarding appropriate drawer events for a period of time.) */ public void syncState() { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mSlider.setPosition(1); } else { mSlider.setPosition(0); } if (mDrawerIndicatorEnabled) { setActionBarUpIndicator( (Drawable) mSlider, mDrawerLayout.isDrawerOpen(GravityCompat.START) ? mCloseDrawerContentDescRes : mOpenDrawerContentDescRes); } }
/** * {@link DrawerLayout.DrawerListener} callback method. If you do not use your * ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call * through to this method from your own listener object. * * @param drawerView Drawer view that is now closed */ @Override public void onDrawerClosed(View drawerView) { mSlider.setPosition(0); if (mDrawerIndicatorEnabled) { setActionBarDescription(mOpenDrawerContentDescRes); } }
/** * {@link DrawerLayout.DrawerListener} callback method. If you do not use your * ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call * through to this method from your own listener object. * * @param drawerView The child view that was moved * @param slideOffset The new offset of this drawer within its range, from 0-1 */ @Override public void onDrawerSlide(View drawerView, float slideOffset) { mSlider.setPosition(Math.min(1f, Math.max(0, slideOffset))); }