/** * Set a {@link Toolbar} to act as the {@link android.support.v7.app.ActionBar}ActionBar for this * Activity window. You must take care of hiding the old {@link Toolbar} if necessary. * * @param toolbar Toolbar to set as the Activity's action bar */ @Override public void setSupportActionBar(@Nullable Toolbar toolbar) { if (toolbar != null) { if (toolbar != mDefaultToolbar && mDefaultToolbar.getVisibility() != View.GONE) { mDefaultToolbar.setVisibility(View.GONE); } super.setSupportActionBar(toolbar); mDrawerToggle = new ActionBarDrawerToggle( this, mDrawer, toolbar, R.string.md_content_description_drawer_open, R.string.md_content_description_drawer_close) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); } }; mDrawerToggle.syncState(); mDrawer.setDrawerListener(mDrawerToggle); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.md_drawer_activity); mDrawer = (DrawerFrameLayout) findViewById(R.id.mdDrawerLayout); mDefaultToolbar = (Toolbar) findViewById(R.id.mdToolbar); mFrame = (FrameLayout) findViewById(R.id.mdFrame); setSupportActionBar(mDefaultToolbar); mDrawer.closeDrawer(); }
/** Removes all profiles from the drawer view */ public DrawerActivity clearProfiles() { mDrawer.clearProfiles(); return this; }
/** Opens the drawer */ public void openDrawer() { mDrawer.openDrawer(); }
/** * Gets whether the drawer has a fixed item click listener set to it * * @return True if the drawer has a fixed item click listener set to it, false otherwise. */ public boolean hasOnFixedItemClickListener() { return mDrawer.hasOnFixedItemClickListener(); }
/** * Sets a fixed item click listener to the drawer * * @param listener Listener to set */ public DrawerActivity setOnFixedItemClickListener(DrawerItem.OnItemClickListener listener) { mDrawer.setOnFixedItemClickListener(listener); return this; }
/** * Removes a fixed item from the drawer * * @param id ID to remove */ public DrawerActivity removeFixedItemById(long id) { mDrawer.removeFixedItemById(id); return this; }
/** * Removes a fixed item from the drawer * * @param position Position to remove */ public DrawerActivity removeFixedItem(int position) { mDrawer.removeFixedItem(position); return this; }
/** * Selects a fixed item from the drawer * * @param id The item ID */ public void selectFixedItemById(long id) { mDrawer.selectFixedItemById(id); }
/** Removes the profile switch listener from the drawer */ public DrawerActivity removeOnProfileSwitchListener() { mDrawer.removeOnProfileSwitchListener(); return this; }
/** * Gets whether the drawer has a profile switch listener set to it * * @return True if the drawer has a profile switch listener set to it, false otherwise. */ public boolean hasOnProfileSwitchListener() { return mDrawer.hasOnProfileSwitchListener(); }
/** * Gets the profile switch listener of the drawer * * @return Profile switch listener of the drawer */ public DrawerProfile.OnProfileSwitchListener getOnProfileSwitchListener() { return mDrawer.getOnProfileSwitchListener(); }
/** * Sets a profile switch listener to the drawer * * @param listener Listener to set */ public DrawerActivity setOnProfileSwitchListener(DrawerProfile.OnProfileSwitchListener listener) { mDrawer.setOnProfileSwitchListener(listener); return this; }
/** * Gets whether the drawer has a profile click listener set to it * * @return True if the drawer has a profile click listener set to it, false otherwise. */ public boolean hasOnProfileClickListener() { return mDrawer.hasOnProfileClickListener(); }
/** * Gets the profile click listener of the drawer * * @return Profile click listener of the drawer */ public DrawerProfile.OnProfileClickListener getOnProfileClickListener() { return mDrawer.getOnProfileClickListener(); }
/** * Selects a fixed item from the drawer * * @param position The item position */ public void selectFixedItem(int position) { mDrawer.selectFixedItem(position); }
/** * Gets the selected fixed item position of the drawer * * @return Position of the selected item */ public int getSelectedFixedPosition() { return mDrawer.getSelectedFixedPosition(); }
/** * Adds fixed items to the drawer * * @param items Items to add */ public DrawerActivity addFixedItems(List<DrawerItem> items) { mDrawer.addFixedItems(items); return this; }
/** * Removes a fixed item from the drawer * * @param item Item to remove */ public DrawerActivity removeFixedItem(DrawerItem item) { mDrawer.removeFixedItem(item); return this; }
/** * Adds fixed items to the drawer * * @param items Items to add */ public DrawerActivity addFixedItems(DrawerItem... items) { mDrawer.addFixedItems(items); return this; }
/** * Adds a fixed item to the drawer * * @param item Item to add */ public DrawerActivity addFixedItem(DrawerItem item) { mDrawer.addFixedItem(item); return this; }
/** Adds a fixed divider to the drawer */ public DrawerActivity addFixedDivider() { mDrawer.addFixedDivider(); return this; }
/** Removes all fixed items from the drawer */ public DrawerActivity clearFixedItems() { mDrawer.clearFixedItems(); return this; }
/** * Gets all fixed items from the drawer * * @return Items from the drawer */ public List<DrawerItem> getFixedItems() { return mDrawer.getFixedItems(); }
/** * Gets the fixed item click listener of the drawer * * @return Item click listener of the drawer */ public DrawerItem.OnItemClickListener getOnFixedItemClickListener() { return mDrawer.getOnFixedItemClickListener(); }
/** * Gets a fixed item from the drawer * * @param position The item position * @return Item from the drawer */ public DrawerItem getFixedItem(int position) { return mDrawer.getFixedItem(position); }
/** Removes the fixed item click listener from the drawer */ public DrawerActivity removeOnFixedItemClickListener() { mDrawer.removeOnFixedItemClickListener(); return this; }
/** * Gets a fixed item from the drawer * * @param id The item ID * @return Item from the drawer */ public DrawerItem findFixedItemById(long id) { mDrawer.findFixedItemById(id); return null; }
/** Closes the drawer */ public void closeDrawer() { mDrawer.closeDrawer(); }
/** * Removes a profile from the drawer view * * @param id ID to remove */ public DrawerActivity removeProfileById(long id) { mDrawer.removeProfileById(id); return this; }