Search in sources :

Example 36 with MaterialMenu

use of de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu in project AdvancedMaterialDrawer by madcyph3r.

the class LightThemeActivity 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 the light theme. You can set the light theme to the application " + "or activity tag in the AndroidManifest.xml . See android:theme=\"@style/MaterialNavigationDrawerTheme.Light\" in the " + "activity tag for this activity.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Light Theme"));
    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) 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)

Example 37 with MaterialMenu

use of de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialNavHeadItemActivity method switchHeadItemsIcon.

private void switchHeadItemsIcon(final MaterialHeadItem newFirstHeadItem, boolean animation) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && animation) {
        // change with animation
        switchHeadItemsIconApi14(newFirstHeadItem);
    } else {
        // change no animation
        changeHeadItems(headItemManager.get(0), newFirstHeadItem);
        notifyHeadItemsDataChanged();
        if (newFirstHeadItem.getMenu() != null && newFirstHeadItem.getMenu().getItems() != null && newFirstHeadItem.getMenu().getItems().size() > 0) {
            MaterialMenu menu = newFirstHeadItem.getMenu();
            // load fragment on headitem change
            if (menu != currentMenu) {
                loadMenu(menu);
                sectionFragmentLastBackPatternList.clear();
                if (newFirstHeadItem.isLoadFragmentOnChanged()) {
                    loadStartFragmentFromMenu(menu, "isLoadFragmentOnChanged is true, but the menu has no" + " MaterialItemSectionFragment. Add one MaterialItemSectionFragment or set" + " isLoadFragmentOnStartFromMenu to false and set your own fragment");
                } else if (currentMenu.getItems().contains(getCurrentSectionFragment())) {
                    getCurrentSectionFragment().select();
                }
            } else if (currentMenu.getItems().contains(getCurrentSectionFragment())) {
                getCurrentSectionFragment().select();
            }
            if (headItemManager.get(0).isCloseDrawerOnChanged() && !deviceSupportMultiPane()) {
                drawerLayout.closeDrawer(drawerViewGroup);
            }
        }
        // set switcher button to default
        headItemButtonSwitcher.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
        headItemSwitcherOpen = false;
    }
}
Also used : MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)

Example 38 with MaterialMenu

use of de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialNavHeadItemActivity method initHeaderAndMenu.

private void initHeaderAndMenu(Bundle savedInstanceState) {
    // init headitem views
    if (headItemManager.size() > 0) {
        // currentHeadItem = headItemManager.get(0);
        notifyHeadItemsDataChanged();
    } else {
        throw new RuntimeException("No head item");
    }
    if (headItemManager.get(0).getMenu() != null) {
        MaterialMenu menu = headItemManager.get(0).getMenu();
        loadMenu(menu);
        // load fragment on start from menu
        if (isLoadFragmentOnStartFromMenu()) {
            loadStartFragmentFromMenu(menu, "isLoadFragmentOnStartFromMenu is true, but the menu has no MaterialItemSectionFragment. Add one MaterialItemSectionFragment or set isLoadFragmentOnStartFromMenu to false and set your own fragment");
        }
    }
}
Also used : MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)

Example 39 with MaterialMenu

use of de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu in project AdvancedMaterialDrawer by madcyph3r.

the class MultiPaneSupportActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "If you have a tablet, the drawer will be always shown. See " + "the styles.xml for the tablet support.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "MultiPane (Tablet) Support"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemLabel(this, "Sections"));
    menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1"));
    // load menu
    this.loadMenu(menu);
    // load first MaterialItemSectionFragment in the menu, because there is no start position
    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) MaterialItemLabel(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel) 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)

Example 40 with MaterialMenu

use of de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu in project AdvancedMaterialDrawer by madcyph3r.

the class MultiPaneSupportBelowToolbarActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "If you have a tablet, the drawer will be always shown under the toolbar.\" +\n" + "                \" See the styles.xml for the tablet and below toolbar support.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "MultiPane (Tablet) And Below ToolBar Support"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemLabel(this, "Sections"));
    menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1"));
    // load menu
    this.loadMenu(menu);
    // load first MaterialItemSectionFragment in the menu, because there is no start position
    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) MaterialItemLabel(de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel) 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)

Aggregations

MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)79 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)72 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)66 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)49 Bundle (android.os.Bundle)48 Fragment (android.support.v4.app.Fragment)48 MaterialHeadItem (de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem)40 TextDrawable (com.amulyakhare.textdrawable.TextDrawable)22 Bitmap (android.graphics.Bitmap)18 RoundedCornersDrawable (de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable)18 MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)11 View (android.view.View)8 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)7 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)5 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)5 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)4 Intent (android.content.Intent)3 ImageView (android.widget.ImageView)2 MaterialItemSectionActivity (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity)2 Animator (android.animation.Animator)1