示例#1
0
 public void onDrawerSlide(View view, float f) {
   float f1 = mSlider.getPosition();
   if (f > 0.5F) {
     f = Math.max(f1, Math.max(0.0F, f - 0.5F) * 2.0F);
   } else {
     f = Math.min(f1, f * 2.0F);
   }
   mSlider.setPosition(f);
 }
 /**
  * {@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);
 }
 /**
  * {@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);
   }
 }
示例#4
0
 public void syncState() {
   if (mDrawerLayout.isDrawerOpen(0x800003)) {
     mSlider.setPosition(1.0F);
   } else {
     mSlider.setPosition(0.0F);
   }
   if (mDrawerIndicatorEnabled) {
     SlideDrawable slidedrawable = mSlider;
     int i;
     if (mDrawerLayout.isDrawerOpen(0x800003)) {
       i = mCloseDrawerContentDescRes;
     } else {
       i = mOpenDrawerContentDescRes;
     }
     setActionBarUpIndicator(slidedrawable, i);
   }
 }
  /**
   * 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);
    }
  }
  /**
   * Construct a new ActionBarDrawerToggle.
   *
   * <p>
   *
   * <p>The given {@link android.app.Activity} will be linked to the specified {@link
   * android.support.v4.widget.DrawerLayout}. The provided drawer indicator drawable will animate
   * slightly off-screen as the drawer is opened, indicating that in the open state the drawer will
   * move off-screen when pressed and in the closed state the drawer will move on-screen when
   * pressed.
   *
   * <p>
   *
   * <p>String resources must be provided to describe the open/close drawer actions for
   * accessibility services.
   *
   * @param activity The Activity hosting the drawer
   * @param drawerLayout The DrawerLayout to link to the given Activity's ActionBar
   * @param drawerImageRes A Drawable resource to use as the drawer indicator
   * @param openDrawerContentDescRes A String resource to describe the "open drawer" action for
   *     accessibility
   * @param closeDrawerContentDescRes A String resource to describe the "close drawer" action for
   *     accessibility
   */
  public ActionBarDrawerToggle(
      SherlockFragmentActivity activity,
      DrawerLayout drawerLayout,
      int drawerImageRes,
      int openDrawerContentDescRes,
      int closeDrawerContentDescRes) {
    mActivity = activity;
    mDrawerLayout = drawerLayout;
    mDrawerImageResource = drawerImageRes;
    mOpenDrawerContentDescRes = openDrawerContentDescRes;
    mCloseDrawerContentDescRes = closeDrawerContentDescRes;

    mThemeImage = IMPL.getThemeUpIndicator(activity);
    mDrawerImage = activity.getResources().getDrawable(drawerImageRes);
    mSlider = new SlideDrawable(mDrawerImage);
    mSlider.setOffsetBy(1.f / 3);
  }
示例#7
0
 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);
 }
示例#8
0
 public void onDrawerOpened(View view) {
   mSlider.setPosition(1.0F);
   if (mDrawerIndicatorEnabled) {
     setActionBarDescription(mCloseDrawerContentDescRes);
   }
 }