Search in sources :

Example 21 with MaterialHeadItem

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

the class HeadItemThreeActivity method getHeadItem3.

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

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

the class HeadItemOneAvatarOnClickListenerActivity 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 click on the avatar image from the head item.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Head Item Style (One Item), Avatar OnClick Listener"));
    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, "My HeadItem", "My Subtitle", drawableAppIcon, R.drawable.mat1, menu);
    // set Avatar on click listener
    headItem.setAvatarOnClickListener(new MaterialHeadItemAvatarOnClickListener() {

        @Override
        public void onClick(MaterialHeadItem headItem) {
            Toast.makeText(drawer, "avatar on click", Toast.LENGTH_LONG).show();
        }
    });
    this.addHeadItem(headItem);
    // load menu
    this.loadMenu(getCurrentHeadItem().getMenu());
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(getCurrentHeadItem().getMenu());
}
Also used : Bitmap(android.graphics.Bitmap) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) MaterialHeadItemAvatarOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemAvatarOnClickListener) 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 23 with MaterialHeadItem

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

the class HeadItemOneBackgroundOnClickListenerActivity 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 click on the background image from the head item.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Head Item Style (One Item), Background OnClick Listener"));
    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, "My HeadItem", "My Subtitle", drawableAppIcon, R.drawable.mat1, menu);
    // set Avatar on click listener
    headItem.setBackgroundOnClickListener(new MaterialHeadItemBackgroundOnClickListener() {

        @Override
        public void onClick(MaterialHeadItem headItem) {
            Toast.makeText(drawer, "background on click", Toast.LENGTH_LONG).show();
        }
    });
    this.addHeadItem(headItem);
    // load menu
    this.loadMenu(getCurrentHeadItem().getMenu());
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(getCurrentHeadItem().getMenu());
}
Also used : Bitmap(android.graphics.Bitmap) MaterialItemSectionFragment(de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment) Bundle(android.os.Bundle) RoundedCornersDrawable(de.madcyph3r.materialnavigationdrawer.tools.RoundedCornersDrawable) MaterialHeadItemBackgroundOnClickListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemBackgroundOnClickListener) 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 24 with MaterialHeadItem

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

the class HeadItemThreeChangeListenerActivity method getHeadItem1.

private MaterialHeadItem getHeadItem1() {
    // information text for the fragment
    Bundle bundle = new Bundle();
    bundle.putString("instruction", "Change the head item and the listener is called.\" +\n" + "                \" You will see a toast message.");
    Fragment fragmentInstruction = new FragmentInstruction();
    fragmentInstruction.setArguments(bundle);
    // create menu
    MaterialMenu menu = new MaterialMenu();
    menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "HeadItem Change Listener"));
    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);
    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 25 with MaterialHeadItem

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

the class HeadItemThreeChangeListenerActivity 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());
    // set the listener
    this.setHeadItemOnChangeListener(new MaterialHeadItemChangeListener() {

        @Override
        public void onBeforeChangeHeadItem(MaterialHeadItem newHeadItem) {
            Toast.makeText(drawer, "before change head item", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAfterChangeHeadItem(MaterialHeadItem newHeadItem) {
            Toast.makeText(drawer, "after change head item", Toast.LENGTH_SHORT).show();
        }
    });
    // load menu
    this.loadMenu(getCurrentHeadItem().getMenu());
    // load the MaterialItemSectionFragment, from the given startIndex
    this.loadStartFragmentFromMenu(getCurrentHeadItem().getMenu());
}
Also used : MaterialHeadItem(de.madcyph3r.materialnavigationdrawer.head.MaterialHeadItem) MaterialHeadItemChangeListener(de.madcyph3r.materialnavigationdrawer.listener.MaterialHeadItemChangeListener)

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