Search in sources :

Example 16 with MaterialHeadItem

use of de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItem100StaticBackgroundActivity method getHeadItem.

private MaterialHeadItem getHeadItem(int pos) {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    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.head_item_icon);
    final RoundedCornersDrawable drawableAppIcon = new RoundedCornersDrawable(getResources(), bitmap);
    MaterialHeadItem headItem = new MaterialHeadItem(this, pos + " HeadItem", pos + " Subtitle", drawableAppIcon, menu);
    return headItem;
}
Also used : Bitmap(android.graphics.Bitmap) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) RoundedCornersDrawable(de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable) MaterialMenu(de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu) MaterialHeadItem(de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem) FragmentDummy(de.madcyph3r.example.example.FragmentDummy)

Example 17 with MaterialHeadItem

use of de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItemFiveDontCloseOnChangeActivity 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. " + "If a new head item is chosen, the drawer will not close. ");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Don't Close Drawer On HeadItem Change (Five Items)"));
    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.head_item_icon);
    final RoundedCornersDrawable drawableAppIcon = new RoundedCornersDrawable(getResources(), bitmap);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "A HeadItem", "A Subtitle", drawableAppIcon, R.drawable.mat1, menu);
    // don't close the drawer, if this head item chosen
    headItem.setCloseDrawerOnChanged(false);
    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 18 with MaterialHeadItem

use of de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItemFiveDontCloseOnChangeActivity method getHeadItem2.

private MaterialHeadItem getHeadItem2() {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    // create Head Item
    TextDrawable headPhoto = TextDrawable.builder().buildRound("B", Color.BLUE);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "B 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)

Example 19 with MaterialHeadItem

use of de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItemThreeChangeListenerActivity method getHeadItem2.

private MaterialHeadItem getHeadItem2() {
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Section 1 (Head 2)", new FragmentDummy(), "Section 1 (Head 2)"));
    menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
    // create Head Item
    TextDrawable headPhoto = TextDrawable.builder().buildRound("B", Color.BLUE);
    MaterialHeadItem headItem = new MaterialHeadItem(this, "B HeadItem", "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 20 with MaterialHeadItem

use of de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem 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)

Aggregations

MaterialHeadItem (de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem)43 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)40 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)40 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)39 TextDrawable (com.amulyakhare.textdrawable.TextDrawable)23 Bitmap (android.graphics.Bitmap)18 RoundedCornersDrawable (de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable)18 Bundle (android.os.Bundle)17 Fragment (android.support.v4.app.Fragment)17 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)17 SuppressLint (android.annotation.SuppressLint)1 Point (android.graphics.Point)1 View (android.view.View)1 MaterialHeadItemAvatarOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemAvatarOnClickListener)1 MaterialHeadItemBackgroundOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemBackgroundOnClickListener)1 MaterialHeadItemChangeListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemChangeListener)1 MaterialSectionOnClickListener (de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionOnClickListener)1 MaterialItemSection (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSection)1 MaterialItemSectionOnClick (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionOnClick)1 MaterialItemDevisor (de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor)1