Search in sources :

Example 66 with MaterialMenu

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

the class BackPatternStartIndexActivity method init.

@Override
public void init(Bundle savedInstanceState) {
    drawer = this;
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "On the back button the start section will be selected and opened.\" +\n" + "                \" If the start section open, it will call super.onBackPressed() method.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "StartIndex Back Pattern"));
    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"));
    menu.setStartIndex(3);
    // load menu
    this.loadMenu(menu);
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(menu);
    // set back pattern
    this.setBackPattern(MaterialNavigationDrawer.BACKPATTERN_BACK_TO_START_INDEX);
}
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 67 with MaterialMenu

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

the class AddRemoveHeadItemRuntimeActivity method getHeadItem1.

private MaterialHeadItem getHeadItem1() {
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Here you can add new head-items and/or remove existing head-items. " + "Open the menu and choose the action you want.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create sections
    MaterialItemSectionFragment instruction = new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Add Remove HeadItem At Runtime");
    MaterialItemSectionOnClick addSection = new MaterialItemSectionOnClick(this, "Add Head Item");
    MaterialItemSectionOnClick removeSection = new MaterialItemSectionOnClick(this, "Remove Last Head Item");
    // add OnClickListener to MaterialItemSectionOnClick sections
    addSection.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View view) {
            // add headItem, true is needed for view change
            drawer.addHeadItem(getHeadItem3(), true);
        }
    });
    removeSection.setOnSectionClickListener(new MaterialSectionOnClickListener() {

        @Override
        public void onClick(MaterialItemSection section, View view) {
            if (drawer.getHeadItemManager().size() > 1)
                drawer.removeHeadItem(drawer.getHeadItemManager().size() - 1);
            else
                Toast.makeText(drawer, "You can't remove all head-items.", Toast.LENGTH_SHORT).show();
        }
    });
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(instruction);
    menu.add(addSection);
    menu.add(removeSection);
    // create headItem
    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.head_item_icon);
    final RoundedCornersDrawable drawableAppIcon = new RoundedCornersDrawable(getResources(), bitmap);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "A HeadItem", "A Subtitle", drawableAppIcon, R.drawable.mat1, menu);
    return headItem;
}
Also used : Bundle(android.os.Bundle) MaterialItemSectionOnClick(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) FragmentInstruction(de.madcyph3r.example.example.FragmentInstruction) Fragment(android.support.v4.app.Fragment) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) View(android.view.View) MaterialSectionOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener) Bitmap(android.graphics.Bitmap) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) RoundedCornersDrawable(de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable) MaterialHeadItem(de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem) MaterialItemSection(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)

Example 68 with MaterialMenu

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

the class AddRemoveHeadItemRuntimeActivity method getHeadItem2.

private MaterialHeadItem getHeadItem2() {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Section 1", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Section 1"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    // create headItem
    TextDrawable headPhoto = TextDrawable.builder().buildRound("B", Color.BLUE);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem No Menu", "B Subtitle", headPhoto, R.drawable.mat6, menu);
    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)

Example 69 with MaterialMenu

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

the class AddRemoveHeadItemRuntimeActivity method getHeadItem3.

private MaterialHeadItem getHeadItem3() {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head " + headCount + ")", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Section 1 (Head " + headCount + ")"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2 (Head " + headCount + ")", new FragmentDummy(), "Section 2 (Head " + headCount + ")"));
    // create headItem
    TextDrawable headPhoto = TextDrawable.builder().buildRound(headCount + "", Color.BLUE);
    MaterialHeadItem headItem = new MaterialHeadItem(this, headCount + " HeadItem No Menu", headCount + " Subtitle", headPhoto, R.drawable.mat6, menu);
    // counter for the new headItem
    headCount++;
    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)

Example 70 with MaterialMenu

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

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