Search in sources :

Example 11 with MaterialItemDevisor

use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor 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)

Example 12 with MaterialItemDevisor

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

the class ActionBarOverlayActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Open the menu and press the section 'Show Overlay', to see it." + " To add overlay support, see 'android:theme=\"@style/ActionBarOverlayTheme\"' in the AndroidManifest.xml and the" + " part for this activity." + " The style is defined in the styles.xml with the name ActionBarOverlayTheme. " + "Or set it on runtime. For this, see the source code from this example.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Actionbar Overlay"));
    menu.add(new MaterialItemSectionFragment(this, "Show Overlay", new FragmentActionBarOverlay(), "Show Overlay"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    menu.add(new MaterialItemSectionFragment(this, "Section 3", new FragmentDummy(), "Section 3"));
    // load menu
    this.loadMenu(menu);
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) FragmentDummy(de.madcyph3r.example.example.FragmentDummy) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) FragmentActionBarOverlay(de.madcyph3r.example.example.theme.actionBarOverlayActivity.FragmentActionBarOverlay)

Aggregations

MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)12 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)11 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)11 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)11 Bundle (android.os.Bundle)10 Fragment (android.support.v4.app.Fragment)10 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)6 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)6 Intent (android.content.Intent)3 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)3 MaterialItemSectionActivity (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity)3 View (android.view.View)2 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)2 MaterialItemCustom (de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom)2 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)2 SuppressLint (android.annotation.SuppressLint)1 Bitmap (android.graphics.Bitmap)1 ImageView (android.widget.ImageView)1 FragmentActionBarButtons (de.madcyph3r.example.example.functionally.actionBarButtonsActivity.FragmentActionBarButtons)1 MasterFragment (de.madcyph3r.example.example.functionally.masterChildNavActivity.MasterFragment)1