/** * {@link android.support.v4.widget.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.setOffset(0.f); if (mDrawerIndicatorEnabled) { mSetIndicatorInfo = IMPL.setActionBarDescription(mSetIndicatorInfo, mActivity, mCloseDrawerContentDescRes); } }
/** * Synchronize the state of the drawer indicator/affordance with the linked DrawerLayout. * * <p> * * <p>This should be called from your <code>Activity</code>'s {@link * android.app.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.setOffset(1.f); } else { mSlider.setOffset(0.f); } if (mDrawerIndicatorEnabled) { mSetIndicatorInfo = IMPL.setActionBarUpIndicator( mSetIndicatorInfo, mActivity, mSlider, mDrawerLayout.isDrawerOpen(GravityCompat.START) ? mOpenDrawerContentDescRes : mCloseDrawerContentDescRes); } }
/** * {@link android.support.v4.widget.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) { float glyphOffset = mSlider.getOffset(); if (slideOffset > 0.5f) { glyphOffset = Math.max(glyphOffset, Math.max(0.f, slideOffset - 0.5f) * 2); } else { glyphOffset = Math.min(glyphOffset, slideOffset * 2); } mSlider.setOffset(glyphOffset); }
public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerlayout, int i, int j, int k) { mDrawerIndicatorEnabled = true; mActivity = activity; if (activity instanceof DelegateProvider) { mActivityImpl = ((DelegateProvider) activity).getDrawerToggleDelegate(); } else { mActivityImpl = null; } mDrawerLayout = drawerlayout; mDrawerImageResource = i; mOpenDrawerContentDescRes = j; mCloseDrawerContentDescRes = k; mThemeImage = getThemeUpIndicator(); mDrawerImage = activity.getResources().getDrawable(i); mSlider = new SlideDrawable(mDrawerImage); mSlider.setOffset(0.3333333F); }