/** * Constructor to use when creating the menu drawer. * * @param activity The activity the menu drawer will be attached to. * @param dragMode The drag mode of the drawer. Can be either {@link MenuDrawer#MENU_DRAG_CONTENT} * or {@link MenuDrawer#MENU_DRAG_WINDOW}. */ public MenuDrawerManager(Activity activity, int dragMode) { mActivity = activity; mDragMode = dragMode; mMenuDrawer = new MenuDrawer(activity); mMenuDrawer.setDragMode(dragMode); mMenuDrawer.setId(R.id.md__layout); mMenuContainer = (ViewGroup) mMenuDrawer.findViewById(R.id.md__menu); mContentContainer = (ViewGroup) mMenuDrawer.findViewById(R.id.md__content); attachMenuLayout(); }
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); final int offsetPixels = (int) mOffsetPixels; if (offsetPixels != 0) drawMenuOverlay(canvas, offsetPixels); if (mDropShadowEnabled) drawDropShadow(canvas, offsetPixels); if (mActiveIndicator != null) drawIndicator(canvas, offsetPixels); }
public void restoreState(Parcelable in) { super.restoreState(in); Bundle state = (Bundle) in; final boolean menuOpen = state.getBoolean(STATE_MENU_VISIBLE); if (menuOpen) { openMenu(false); } else { setOffsetPixels(0); } mDrawerState = menuOpen ? STATE_OPEN : STATE_CLOSED; }
@Override protected void initDrawer(Context context, AttributeSet attrs, int defStyle) { super.initDrawer(context, attrs, defStyle); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaxVelocity = configuration.getScaledMaximumFlingVelocity(); mScroller = new Scroller(context, MenuDrawer.SMOOTH_INTERPOLATOR); mPeekScroller = new Scroller(context, DraggableDrawer.PEEK_INTERPOLATOR); mCloseEnough = dpToPx(DraggableDrawer.CLOSE_ENOUGH); }
/** * Called to restore the MenuDrawer's state that has previously been generated with {@link * #onSaveDrawerState()}. * * @param in The state that had previously been returned by {@link #onSaveDrawerState()}. */ public void onRestoreDrawerState(Parcelable in) { mRestoredState = (Bundle) in; mMenuDrawer.restoreState(mRestoredState.getParcelable(STATE_LAYOUT)); }
/** * Returns the views current state. * * @return Returns a Parcelable object containing the MenuDrawer's current state. */ public Parcelable onSaveDrawerState() { Bundle state = new Bundle(); state.putParcelable(STATE_LAYOUT, mMenuDrawer.saveState()); return state; }
/** * Returns the state of the drawer. Can be one of {@link MenuDrawer#STATE_CLOSED}, {@link * MenuDrawer#STATE_CLOSING}, {@link MenuDrawer#STATE_DRAGGING}, {@link MenuDrawer#STATE_OPENING} * or {@link MenuDrawer#STATE_OPEN}. * * @return The drawers state. */ public int getDrawerState() { return mMenuDrawer.getDrawerState(); }
/** * Indicates whether the menu is currently visible. * * @return True if the menu is open, false otherwise. */ public boolean isMenuVisible() { return mMenuDrawer.isMenuVisible(); }
/** * Closes the menu. * * @param animate Whether open/close should be animated. */ public void closeMenu(boolean animate) { mMenuDrawer.closeMenu(animate); }
/** Closes the menu. */ public void closeMenu() { mMenuDrawer.closeMenu(); }
/** * Opens the menu. * * @param animate Whether open/close should be animated. */ public void openMenu(boolean animate) { mMenuDrawer.openMenu(animate); }
/** Opens the menu. */ public void openMenu() { mMenuDrawer.openMenu(); }
/** * Toggles the menu open and close. * * @param animate Whether open/close should be animated. */ public void toggleMenu(boolean animate) { mMenuDrawer.toggleMenu(animate); }
/** Toggles the menu open and close. */ public void toggleMenu() { mMenuDrawer.toggleMenu(); }
/** * Set the active view. If the mdArrowDrawable attribute is set, this View will have an arrow * drawn next to it. * * @param v The active view. * @param position Optional position, usually used with ListView. * v.setTag(R.id.mdActiveViewPosition, position) must be called first. */ public void setActiveView(View v, int position) { mMenuDrawer.setActiveView(v, position); }