Search in sources :

Example 66 with MaterialItemSectionFragment

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

the class ClosePrevDrawerActivity_Activity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Open the drawer and choose the 'start activity' section. \" +\n" + "                \"This activity will be closed. You get Back to the latest non closed (not finish()) activity.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Close Previous Drawer Activity"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionActivity(this, "start Activity", new Intent(this, CloseActivity.class)));
    // load menu
    this.loadMenu(menu);
    // load first MaterialItemSectionFragment in the menu, because there is no start position
    this.loadStartFragmentFromMenu(menu);
}
Also used : MaterialItemSectionActivity(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity) 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) Intent(android.content.Intent) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)

Example 67 with MaterialItemSectionFragment

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

the class MasterChildNavActivity 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 a master child navigation. At the child in 'Master 2' you can open the menu with sliding." + "At the child in 'Master 1' the menu is locked. You can't open it.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Master Child Navigation"));
    menu.add(new MaterialItemDevisor());
    menu.add(new MaterialItemSectionFragment(this, "Master 1", new MasterFragment(), "Master 1"));
    menu.add(new MaterialItemSectionFragment(this, "Master 2", new MasterFragment2(), "Master 2"));
    // 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) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) MasterFragment(de.madcyph3r.example.example.functionally.masterChildNavActivity.MasterFragment) Fragment(android.support.v4.app.Fragment) MasterFragment(de.madcyph3r.example.example.functionally.masterChildNavActivity.MasterFragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) MasterFragment2(de.madcyph3r.example.example.functionally.masterChildNavActivity.MasterFragment2)

Example 68 with MaterialItemSectionFragment

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

the class ChildFragment2 method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Get item selected and deal with it
    switch(item.getItemId()) {
        case android.R.id.home:
            // your back action, here get the last section fragment called
            // show the menu button and unlock the drawer
            drawer.showActionBarMenuIcon(MaterialNavigationDrawer.ActionBarMenuItem.MENU);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            MaterialItemSectionFragment fragmentSection = drawer.getCurrentSectionFragment();
            // set the fragment from the selected section
            drawer.changeFragment(fragmentSection.getFragment(), fragmentSection.getFragmentTitle());
            // normally currentSection gets unselect on setCustomFragment call
            // in the next relase, i will add a new method without unselect
            drawer.getCurrentSectionFragment().select();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)

Example 69 with MaterialItemSectionFragment

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

the class HeadItem100StaticBackgroundActivity method getHeadItem1.

private MaterialHeadItem getHeadItem1() {
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "This example shows the head item style with five items. " + "The first three head items ar shown with a picture. To get the other head items, " + "press the down arrow button in the header. " + "Under the items, you see the extra menu. ");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "100 static HeadItems"));
    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"));
    // create Head Item
    // use bitmap and make a circle photo
    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_drawer_icon);
    final RoundedCornersDrawable drawableAppIcon = new RoundedCornersDrawable(getResources(), bitmap);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "A HeadItem", "A Subtitle", drawableAppIcon, menu);
    return headItem;
}
Also used : Bitmap(android.graphics.Bitmap) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) RoundedCornersDrawable(de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) MaterialHeadItem(de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem) 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 70 with MaterialItemSectionFragment

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

the class HeadItemFiveDontCloseOnChangeActivity method getHeadItem5.

private MaterialHeadItem getHeadItem5() {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 5)", new FragmentDummy(), "Section 1 (Head 5)"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    // create Head Item
    TextDrawable headPhoto = TextDrawable.builder().buildRound("E", Color.GRAY);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "E HeadItem", "E Subtitle", headPhoto, R.drawable.mat6, menu);
    // don't close the drawer, if this head item chosen
    headItem.setCloseDrawerOnChanged(false);
    return headItem;
}
Also used : TextDrawable(com.amulyakhare.textdrawable.TextDrawable) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) MaterialHeadItem(de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem) FragmentDummy(de.madcyph3r.example.example.FragmentDummy)

Aggregations

MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)77 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)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)6 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)6 MaterialItemLabel (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemLabel)5 MaterialItemSectionActivity (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionActivity)4 Intent (android.content.Intent)3 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)3 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)3 SuppressLint (android.annotation.SuppressLint)2 MaterialSectionChangeListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener)2