Search in sources :

Example 1 with CustomPrimaryDrawerItem

use of com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem in project MaterialDrawer by mikepenz.

the class AdvancedActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.drawer_item_advanced_drawer);
    // Create a few sample profile
    profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile));
    profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2)).withIdentifier(2);
    profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3));
    profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4);
    profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
    // Create the AccountHeader
    buildHeader(false, savedInstanceState);
    //Create the drawer
    result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(//set the AccountHeader we created earlier for the header
    headerResult).addDrawerItems(new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), //this custom DrawerItem extends the PrimaryDrawerItem so it just overwrites some methods
    new OverflowMenuDrawerItem().withName(R.string.drawer_item_menu_drawer_item).withDescription(R.string.drawer_item_menu_drawer_item_desc).withMenu(R.menu.fragment_menu).withOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(AdvancedActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
            return false;
        }
    }).withIcon(GoogleMaterial.Icon.gmd_filter_center_focus), new CustomPrimaryDrawerItem().withBackgroundRes(R.color.accent).withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withDescription("This is a description").withIcon(FontAwesome.Icon.faw_eye), new CustomUrlPrimaryDrawerItem().withName(R.string.drawer_item_fragment_drawer).withDescription(R.string.drawer_item_fragment_drawer_desc).withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cart_plus), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_database).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withSelectedIconColor(Color.RED).withIconTintingEnabled(true).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withTag("Bullhorn"), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false)).withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {

        @Override
        public boolean onNavigationClickListener(View clickedView) {
            //this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
            //if the back arrow is shown. close the activity
            AdvancedActivity.this.finish();
            //return true if we have consumed the event
            return true;
        }
    }).addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog).withIdentifier(10), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github)).withSavedInstance(savedInstanceState).build();
}
Also used : CustomUrlPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomUrlPrimaryDrawerItem) CustomPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) CustomUrlPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomUrlPrimaryDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) MenuItem(android.view.MenuItem) Drawer(com.mikepenz.materialdrawer.Drawer) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) SectionDrawerItem(com.mikepenz.materialdrawer.model.SectionDrawerItem) OverflowMenuDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.OverflowMenuDrawerItem) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) CustomPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 Drawer (com.mikepenz.materialdrawer.Drawer)1 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)1 CustomPrimaryDrawerItem (com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem)1 CustomUrlPrimaryDrawerItem (com.mikepenz.materialdrawer.app.drawerItems.CustomUrlPrimaryDrawerItem)1 OverflowMenuDrawerItem (com.mikepenz.materialdrawer.app.drawerItems.OverflowMenuDrawerItem)1 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)1 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)1 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)1 SectionDrawerItem (com.mikepenz.materialdrawer.model.SectionDrawerItem)1