Search in sources :

Example 1 with MaterialItemSection

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItemFiveExtraMenuActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // add head Item (menu will be loaded automatically)
    this.addHeadItem(getHeadItem1());
    this.addHeadItem(getHeadItem2());
    this.addHeadItem(getHeadItem3());
    this.addHeadItem(getHeadItem4());
    this.addHeadItem(getHeadItem5());
    // load menu
    this.loadMenu(getCurrentHeadItem().getMenu());
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(getCurrentHeadItem().getMenu());
    // create switcher extra menu
    MaterialItemSectionOnClick section = new MaterialItemSectionOnClick(this, "do something");
    section.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View view) {
            Toast.makeText(drawer, " do something here", Toast.LENGTH_LONG).show();
        }
    });
    MaterialMenu menu = new MaterialMenu();
    menu.add(section);
    // add menu to switcher
    this.setSwitcherExtraMenu(menu, false);
    // show switch button, even if only one head item
    this.setSwitchShowForce(true);
}
Also used : MaterialSectionOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener) MaterialItemSectionOnClick(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) View(android.view.View) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 2 with MaterialItemSection

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection in project AdvancedMaterialDrawer by madcyph3r.

the class BackPatternCustomActivity method backToSection.

@Override
protected MaterialItemSection backToSection(MaterialItemSection currentSection) {
    // use getCurrentMenu().getSectionPosition, it doesn't considered devisor and label in the list
    // quivalent is getCurrentMenu().getSection(int position)
    // or use getCurrentMenu().getRealSectionPosition, it does considered devisor and label in the list
    // equivalent is getCurrentMenu().getSectionFromRealPosition(int position)
    MaterialItemSection section;
    switch(getCurrentMenu().getSectionPosition(currentSection)) {
        case 3:
            section = getCurrentMenu().getSection(2);
            // remember to change the toolbar color
            this.changeToolbarColor((MaterialItemSection) section);
            break;
        case 2:
            section = getCurrentMenu().getSection(1);
            // remember to change the toolbar color
            this.changeToolbarColor((MaterialItemSection) section);
            break;
        case 1:
            section = getCurrentMenu().getSection(0);
            // remember to change the toolbar color
            this.changeToolbarColor((MaterialItemSection) section);
            break;
        default:
            // exit from activity
            section = super.backToSection(currentSection);
            break;
    }
    return section;
}
Also used : MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 3 with MaterialItemSection

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection in project AdvancedMaterialDrawer by madcyph3r.

the class AddRemoveMenuItemsActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Remove and add menu items at runtime. Open the menu and then " + "you can choose your action.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    final MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Add And Remove Menu Items"));
    menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    MaterialItemSectionOnClick section3 = new MaterialItemSectionOnClick(this, "add two sections and one devisor");
    menu.add(section3);
    section3.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View v) {
            Toast.makeText(drawer, "added two section", Toast.LENGTH_SHORT).show();
            // add two items on the first position
            menu.add(new MaterialItemDevisor());
            menu.add(0, new MaterialItemSectionFragment(drawer, "added two", new FragmentDummy(), "added two"));
            menu.add(0, new MaterialItemSectionFragment(drawer, "added one", new FragmentDummy(), "added one"));
            // reloads the current menu, this is "menu"
            reloadMenu();
        }
    });
    MaterialItemSectionOnClick section4 = new MaterialItemSectionOnClick(this, "add one section at the end");
    menu.add(section4);
    section4.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View v) {
            Toast.makeText(drawer, "added one section", Toast.LENGTH_SHORT).show();
            // add one item on the last position
            menu.add(new MaterialItemDevisor());
            menu.add(new MaterialItemSectionFragment(drawer, "added one", new FragmentDummy(), "added one"));
            // reloads the current menu, this is "menu"
            reloadMenu();
        }
    });
    MaterialItemSectionOnClick section5 = new MaterialItemSectionOnClick(this, "remove first menu item");
    menu.add(section5);
    section5.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View v) {
            if (getCurrentMenu().getItems().size() > 1) {
                Toast.makeText(drawer, "removed first menu item", Toast.LENGTH_SHORT).show();
                // remove first menu item
                getCurrentMenu().getItems().remove(0);
                // reloads the current menu, this is "menu"
                reloadMenu();
            }
        }
    });
    // load menu
    this.loadMenu(menu);
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialSectionOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) MaterialItemSectionOnClick(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick) 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) View(android.view.View) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 4 with MaterialItemSection

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection in project AdvancedMaterialDrawer by madcyph3r.

the class AllMenuTypesActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "This example shows all menu items. " + "Open the drawer and see ;).");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "All Menu Types"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemCustom(this, R.layout.custom_section));
    menu.add(new MaterialItemLabel(this, "Label"));
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section", new FragmentDummy(), "Fragment Section"));
    MaterialItemSectionFragment secNoti = new MaterialItemSectionFragment(this, "Fragment Section Notification", new FragmentDummy(), "Fragment Section Notification");
    secNoti.setNotifications(20);
    menu.add(secNoti);
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section Icon", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Icon"));
    MaterialItemSectionFragment iconBanner = new MaterialItemSectionFragment(this, this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), true, new FragmentDummy(), "Fragment Section Icon Banner");
    //iconBanner.getIconView().setScaleType(ImageView.ScaleType.CENTER);  edit the iconView to your needs
    menu.add(iconBanner);
    menu.add(new MaterialItemSectionFragment(this, "Fragment Section Color Red", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Color Red").setSectionColor(Color.parseColor("#ff0858")));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionActivity(this, "Activity Section", new Intent(this, DummyActivity.class)));
    MaterialItemSectionOnClick onClickSection = new MaterialItemSectionOnClick(this, "OnClick Section");
    onClickSection.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View v) {
            Toast.makeText(drawer, "OnClickSection", Toast.LENGTH_SHORT).show();
        }
    });
    menu.add(onClickSection);
    MaterialItemSectionFragment bottom = new MaterialItemSectionFragment(this, "Fragment Bottom Section", new FragmentDummy(), "Fragment Bottom Section");
    bottom.setBottom(true);
    menu.add(bottom);
    // load menu
    this.loadMenu(menu);
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) Bundle(android.os.Bundle) MaterialItemSectionOnClick(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) MaterialItemCustom(de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom) FragmentDummy(de.madcyph3r.example.example.FragmentDummy) Intent(android.content.Intent) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) ImageView(android.widget.ImageView) View(android.view.View) MaterialSectionOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) MaterialItemDevisor(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor) MaterialItemLabel(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 5 with MaterialItemSection

use of de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection in project AdvancedMaterialDrawer by madcyph3r.

the class ActionBarOwnFontActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    drawer.setSectionChangeListener(new MaterialSectionChangeListener() {

        @Override
        public void onBeforeChangeSection(MaterialItemSection newSection) {
        }

        @Override
        public void onAfterChangeSection(MaterialItemSection newSection) {
            setActionBarTitle(getCurrentSectionFragment().getTitle());
        }
    });
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "See the actionbar, it has a custom title with a custom font.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Actionbar Own Front"));
    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 : MaterialSectionChangeListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) 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) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Aggregations

MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)10 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)7 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)6 Bundle (android.os.Bundle)5 Fragment (android.support.v4.app.Fragment)5 View (android.view.View)5 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)5 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)5 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)5 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)4 MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)3 SuppressLint (android.annotation.SuppressLint)2 MaterialSectionChangeListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener)2 MaterialMenuItem (de.madcyph3r.materialnavigationdrawer.menu.item.MaterialMenuItem)2 MaterialItemCustom (de.madcyph3r.materialnavigationdrawer.menu.item.custom.MaterialItemCustom)2 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ImageView (android.widget.ImageView)1 MaterialHeadItem (de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem)1