use of com.mikepenz.materialdrawer.model.interfaces.IDrawerItem in project MaterialDrawer by mikepenz.
the class Drawer method updateIcon.
/**
* update the name for a specific drawerItem
* identified by its id
*
* @param identifier
* @param image
*/
public void updateIcon(long identifier, ImageHolder image) {
IDrawerItem drawerItem = getDrawerItem(identifier);
if (drawerItem instanceof Iconable) {
Iconable pdi = (Iconable) drawerItem;
pdi.withIcon(image);
updateItem((IDrawerItem) pdi);
}
}
use of com.mikepenz.materialdrawer.model.interfaces.IDrawerItem in project MaterialDrawer by mikepenz.
the class DrawerBuilder method addMenuItems.
/**
* helper method to init the drawerItems from a menu
*
* @param mMenu
* @param subMenu
*/
private void addMenuItems(Menu mMenu, boolean subMenu) {
int groupId = R.id.material_drawer_menu_default_group;
for (int i = 0; i < mMenu.size(); i++) {
MenuItem mMenuItem = mMenu.getItem(i);
IDrawerItem iDrawerItem;
if (!subMenu && mMenuItem.getGroupId() != groupId && mMenuItem.getGroupId() != 0) {
groupId = mMenuItem.getGroupId();
iDrawerItem = new DividerDrawerItem();
getItemAdapter().add(iDrawerItem);
}
if (mMenuItem.hasSubMenu()) {
iDrawerItem = new PrimaryDrawerItem().withName(mMenuItem.getTitle().toString()).withIcon(mMenuItem.getIcon()).withIdentifier(mMenuItem.getItemId()).withEnabled(mMenuItem.isEnabled()).withSelectable(false);
getItemAdapter().add(iDrawerItem);
addMenuItems(mMenuItem.getSubMenu(), true);
} else if (mMenuItem.getGroupId() != 0 || subMenu) {
iDrawerItem = new SecondaryDrawerItem().withName(mMenuItem.getTitle().toString()).withIcon(mMenuItem.getIcon()).withIdentifier(mMenuItem.getItemId()).withEnabled(mMenuItem.isEnabled());
getItemAdapter().add(iDrawerItem);
} else {
iDrawerItem = new PrimaryDrawerItem().withName(mMenuItem.getTitle().toString()).withIcon(mMenuItem.getIcon()).withIdentifier(mMenuItem.getItemId()).withEnabled(mMenuItem.isEnabled());
getItemAdapter().add(iDrawerItem);
}
}
}
use of com.mikepenz.materialdrawer.model.interfaces.IDrawerItem in project MaterialDrawer by mikepenz.
the class ActionBarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_actionbar);
setTitle(R.string.drawer_item_action_bar_drawer);
// Handle Toolbar
result = new DrawerBuilder().withActivity(this).withSavedInstance(savedInstanceState).withDisplayBelowStatusBar(false).withTranslucentStatusBar(false).withDrawerLayout(R.layout.material_drawer_fits_not).addDrawerItems(new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof Nameable) {
Toast.makeText(ActionBarActivity.this, ((Nameable) drawerItem).getName().getText(ActionBarActivity.this), Toast.LENGTH_SHORT).show();
}
return false;
}
}).build();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
use of com.mikepenz.materialdrawer.model.interfaces.IDrawerItem in project MaterialDrawer by mikepenz.
the class DrawerUtils method setStickyFooterSelection.
/**
* helper method to set the selection of the footer
*
* @param drawer
* @param position
* @param fireOnClick
*/
public static void setStickyFooterSelection(DrawerBuilder drawer, int position, Boolean fireOnClick) {
if (position > -1) {
if (drawer.mStickyFooterView != null && drawer.mStickyFooterView instanceof LinearLayout) {
LinearLayout footer = (LinearLayout) drawer.mStickyFooterView;
if (footer.getChildCount() > position && position >= 0) {
IDrawerItem drawerItem = (IDrawerItem) footer.getChildAt(position).getTag();
onFooterDrawerItemClick(drawer, drawerItem, footer.getChildAt(position), fireOnClick);
}
}
}
}
use of com.mikepenz.materialdrawer.model.interfaces.IDrawerItem in project MaterialDrawer by mikepenz.
the class DrawerUtils method fillStickyDrawerItemFooter.
/**
* helper method to fill the sticky footer with it's elements
*
* @param drawer
* @param container
* @param onClickListener
*/
public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) {
//add all drawer items
for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) {
View view = drawerItem.generateView(container.getContext(), container);
view.setTag(drawerItem);
if (drawerItem.isEnabled()) {
//UIUtils.setBackground(view, UIUtils.getSelectableBackground(container.getContext(), selected_color, drawerItem.isSelectedBackgroundAnimated()));
view.setOnClickListener(onClickListener);
}
container.addView(view);
//for android API 17 --> Padding not applied via xml
DrawerUIUtils.setDrawerVerticalPadding(view);
}
//and really. don't ask about this. it won't set the padding if i don't set the padding for the container
container.setPadding(0, 0, 0, 0);
}
Aggregations