Search in sources :

Example 6 with MaterialItemLabel

use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialNavigationDrawer method loadMenu.

// protected abstract MaterialMenu loadMenuType();
protected void loadMenu(MaterialMenu menu, boolean forceReload) {
    if (menu != null && (menu != currentMenu || forceReload)) {
        // set the new current menu
        currentMenu = menu;
        itemSections.removeAllViews();
        itemBottomSections.removeAllViews();
        // create Menu
        List<MaterialMenuItem> itemList = menu.getItems();
        for (int i = 0; i < itemList.size(); i++) {
            if (itemList.get(i) instanceof MaterialItemSection) {
                MaterialItemSection section = (MaterialItemSection) itemList.get(i);
                if (section.isBottom())
                    addBottomSection((MaterialItemSection) itemList.get(i));
                else
                    addSection((MaterialItemSection) itemList.get(i));
            } else if (itemList.get(i) instanceof MaterialItemCustom) {
                MaterialItemCustom custom = (MaterialItemCustom) itemList.get(i);
                if (custom.isBottom())
                    addBottomCustom((MaterialItemCustom) itemList.get(i));
                else
                    addCustom((MaterialItemCustom) itemList.get(i));
            } else if (itemList.get(i) instanceof MaterialItemDevisor) {
                MaterialItemDevisor devisor = (MaterialItemDevisor) itemList.get(i);
                if (devisor.isBottom())
                    addDevisorBottom();
                else
                    addDevisor();
            } else if (itemList.get(i) instanceof MaterialItemLabel) {
                MaterialItemLabel label = (MaterialItemLabel) itemList.get(i);
                if (label.isBottom())
                    addBottomLabel((MaterialItemLabel) itemList.get(i));
                else
                    addLabel((MaterialItemLabel) itemList.get(i));
            }
        }
        // unselect all items
        for (int i = 0; i < itemList.size(); i++) {
            try {
                ((MaterialItemSection) itemList.get(i)).unSelect();
            } catch (ClassCastException e) {
            // nothing to do here
            }
        }
    }
}
Also used : MaterialMenuItem(de.madcyph3r.materialnavigationdrawer.menu.item.MaterialMenuItem) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialItemCustom(de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom) MaterialItemLabel(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel) SuppressLint(android.annotation.SuppressLint) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Aggregations

MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)6 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)6 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)5 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)5 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)5 Bundle (android.os.Bundle)4 Fragment (android.support.v4.app.Fragment)4 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)4 MaterialItemCustom (de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom)2 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 BackPatternFragment (de.madcyph3r.example.fragment.BackPatternFragment)1 DrawerTypesFragment (de.madcyph3r.example.fragment.DrawerTypesFragment)1 FunctionallyFragment (de.madcyph3r.example.fragment.FunctionallyFragment)1 HeadItemTypesFragment (de.madcyph3r.example.fragment.HeadItemTypesFragment)1 HeaderTypesFragment (de.madcyph3r.example.fragment.HeaderTypesFragment)1