/** call this method to trigger the onProfileClick on the MiniDrawer */ public void onProfileClick() { // crossfade if we are cross faded if (mCrossFader != null) { if (mCrossFader.isCrossfaded()) { mCrossFader.crossfade(); } } // update the current profile if (mAccountHeader != null) { IProfile profile = mAccountHeader.getActiveProfile(); if (profile instanceof IDrawerItem) { mDrawerAdapter.setDrawerItem(0, generateMiniDrawerItem((IDrawerItem) profile)); } } }
/** creates the items for the MiniDrawer */ public void createItems() { mDrawerAdapter.clearDrawerItems(); if (mAccountHeader != null) { IProfile profile = mAccountHeader.getActiveProfile(); if (profile instanceof IDrawerItem) { mDrawerAdapter.addDrawerItem(generateMiniDrawerItem((IDrawerItem) profile)); } } if (mDrawer != null) { if (getDrawerItems() != null) { // migrate to miniDrawerItems for (IDrawerItem drawerItem : getDrawerItems()) { IDrawerItem miniDrawerItem = generateMiniDrawerItem(drawerItem); if (miniDrawerItem != null) { mDrawerAdapter.addDrawerItem(miniDrawerItem); } } } } // listener if (mOnMiniDrawerItemClickListener != null) { mDrawerAdapter.setOnClickListener(mOnMiniDrawerItemClickListener); } else { mDrawerAdapter.setOnClickListener( new BaseDrawerAdapter.OnClickListener() { @Override public void onClick(View v, int position, IDrawerItem item) { int type = getMiniDrawerType(item); if (type == ITEM) { // fire the onClickListener also if the specific drawerItem is not Selectable if (item.isSelectable()) { // make sure we are on the original drawerItemList if (mAccountHeader != null && mAccountHeader.isSelectionListShown()) { mAccountHeader.toggleSelectionList(v.getContext()); } // set the selection mDrawer.setSelection(item, true); } else if (mDrawer.getOnDrawerItemClickListener() != null) { // get the original `DrawerItem` from the Drawer as this one will contain all // information mDrawer .getOnDrawerItemClickListener() .onItemClick( v, position, DrawerUtils.getDrawerItem(getDrawerItems(), item.getIdentifier())); } } else if (type == PROFILE) { if (mAccountHeader != null && !mAccountHeader.isSelectionListShown()) { mAccountHeader.toggleSelectionList(v.getContext()); } if (mCrossFader != null) { mCrossFader.crossfade(); } } } }); } mDrawerAdapter.setOnLongClickListener(mOnMiniDrawerItemLongClickListener); mRecyclerView.scrollToPosition(0); }