use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor in project AdvancedMaterialDrawer by madcyph3r.
the class AddRemoveMenuItemsActivity method init.
@Override
public void init(Bundle savedInstanceState) {
drawer = this;
// information text for the fragment
Bundle bundle = new Bundle();
bundle.putString("instruction", "Remove and add menu items at runtime. Open the menu and then " + "you can choose your action.");
Fragment fragmentInstruction = new FragmentInstruction();
fragmentInstruction.setArguments(bundle);
// create menu
final MaterialMenu menu = new MaterialMenu();
menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Add And Remove Menu Items"));
menu.add(new MaterialItemSectionFragment(this, "Section 1", new FragmentDummy(), "Section 1"));
menu.add(new MaterialItemSectionFragment(this, "Section 2", new FragmentDummy(), "Section 2"));
MaterialItemSectionOnClick section3 = new MaterialItemSectionOnClick(this, "add two sections and one devisor");
menu.add(section3);
section3.setOnSectionClickListener(new MaterialSectionOnClickListener() {
@Override
public void onClick(MaterialItemSection section, View v) {
Toast.makeText(drawer, "added two section", Toast.LENGTH_SHORT).show();
// add two items on the first position
menu.add(new MaterialItemDevisor());
menu.add(0, new MaterialItemSectionFragment(drawer, "added two", new FragmentDummy(), "added two"));
menu.add(0, new MaterialItemSectionFragment(drawer, "added one", new FragmentDummy(), "added one"));
// reloads the current menu, this is "menu"
reloadMenu();
}
});
MaterialItemSectionOnClick section4 = new MaterialItemSectionOnClick(this, "add one section at the end");
menu.add(section4);
section4.setOnSectionClickListener(new MaterialSectionOnClickListener() {
@Override
public void onClick(MaterialItemSection section, View v) {
Toast.makeText(drawer, "added one section", Toast.LENGTH_SHORT).show();
// add one item on the last position
menu.add(new MaterialItemDevisor());
menu.add(new MaterialItemSectionFragment(drawer, "added one", new FragmentDummy(), "added one"));
// reloads the current menu, this is "menu"
reloadMenu();
}
});
MaterialItemSectionOnClick section5 = new MaterialItemSectionOnClick(this, "remove first menu item");
menu.add(section5);
section5.setOnSectionClickListener(new MaterialSectionOnClickListener() {
@Override
public void onClick(MaterialItemSection section, View v) {
if (getCurrentMenu().getItems().size() > 1) {
Toast.makeText(drawer, "removed first menu item", Toast.LENGTH_SHORT).show();
// remove first menu item
getCurrentMenu().getItems().remove(0);
// reloads the current menu, this is "menu"
reloadMenu();
}
}
});
// load menu
this.loadMenu(menu);
// load the MaterialItemSectionFragment, from the given startIndex
this.loadStartFragmentFromMenu(menu);
}
use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor in project AdvancedMaterialDrawer by madcyph3r.
the class AllMenuTypesActivity 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 all menu items. " + "Open the drawer and see ;).");
Fragment fragmentInstruction = new FragmentInstruction();
fragmentInstruction.setArguments(bundle);
// create menu
MaterialMenu menu = new MaterialMenu();
menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "All Menu Types"));
menu.add(new MaterialItemDevisor());
menu.add(new MaterialItemCustom(this, R.layout.custom_section));
menu.add(new MaterialItemLabel(this, "Label"));
menu.add(new MaterialItemSectionFragment(this, "Fragment Section", new FragmentDummy(), "Fragment Section"));
MaterialItemSectionFragment secNoti = new MaterialItemSectionFragment(this, "Fragment Section Notification", new FragmentDummy(), "Fragment Section Notification");
secNoti.setNotifications(20);
menu.add(secNoti);
menu.add(new MaterialItemSectionFragment(this, "Fragment Section Icon", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Icon"));
MaterialItemSectionFragment iconBanner = new MaterialItemSectionFragment(this, this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), true, new FragmentDummy(), "Fragment Section Icon Banner");
//iconBanner.getIconView().setScaleType(ImageView.ScaleType.CENTER); edit the iconView to your needs
menu.add(iconBanner);
menu.add(new MaterialItemSectionFragment(this, "Fragment Section Color Red", this.getResources().getDrawable(R.drawable.ic_favorite_black_36dp), new FragmentDummy(), "Fragment Section Color Red").setSectionColor(Color.parseColor("#ff0858")));
menu.add(new MaterialItemDevisor());
menu.add(new MaterialItemSectionActivity(this, "Activity Section", new Intent(this, DummyActivity.class)));
MaterialItemSectionOnClick onClickSection = new MaterialItemSectionOnClick(this, "OnClick Section");
onClickSection.setOnSectionClickListener(new MaterialSectionOnClickListener() {
@Override
public void onClick(MaterialItemSection section, View v) {
Toast.makeText(drawer, "OnClickSection", Toast.LENGTH_SHORT).show();
}
});
menu.add(onClickSection);
MaterialItemSectionFragment bottom = new MaterialItemSectionFragment(this, "Fragment Bottom Section", new FragmentDummy(), "Fragment Bottom Section");
bottom.setBottom(true);
menu.add(bottom);
// load menu
this.loadMenu(menu);
// load the MaterialItemSectionFragment, from the given startIndex
this.loadStartFragmentFromMenu(menu);
}
use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor 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);
}
use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor 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);
}
use of de.madcyph3r.materialnavigationdrawer.menu.item.style.MaterialItemDevisor in project AdvancedMaterialDrawer by madcyph3r.
the class MainActivity method init.
@Override
public void init(Bundle savedInstanceState) {
drawer = this;
// create menu
MaterialMenu menu = new MaterialMenu();
menu.add(new MaterialItemSectionFragment(this, "Instruction", new FragmentInstruction(), "Instruction"));
menu.add(new MaterialItemDevisor());
menu.add(new MaterialItemLabel(this, "Examples"));
menu.add(new MaterialItemSectionFragment(this, "Theme", new ThemeFragment(), "Theme").setSectionColor(Color.parseColor("#ff0000")));
menu.add(new MaterialItemSectionFragment(this, "Drawer Types", new DrawerTypesFragment(), "Drawer Types").setSectionColor(Color.parseColor("#D35400")));
menu.add(new MaterialItemSectionFragment(this, "Header Types", new HeaderTypesFragment(), "Header Types").setSectionColor(Color.parseColor("#01AEA1")));
menu.add(new MaterialItemSectionFragment(this, "Head Item Types", new HeadItemTypesFragment(), "Header Types").setSectionColor(Color.parseColor("#9B59B6")));
menu.add(new MaterialItemSectionFragment(this, "Menu", new MenuFragment(), "Menu").setSectionColor(Color.parseColor("#3498DB")));
menu.add(new MaterialItemSectionFragment(this, "Back Pattern", new BackPatternFragment(), "Back Pattern").setSectionColor(Color.parseColor("#3CD876")));
menu.add(new MaterialItemSectionFragment(this, "Listener", new ListenerFragment(), "Listener").setSectionColor(Color.parseColor("#9D8C84")));
menu.add(new MaterialItemSectionFragment(this, "Functionally", new FunctionallyFragment(), "Functionally").setSectionColor(Color.parseColor("#F1C40F")));
// actionbar overlay
this.setActionBarOverlay(true);
// load menu
this.loadMenu(menu);
// load first MaterialItemSectionFragment in the menu, because there is no start position
this.loadStartFragmentFromMenu(menu);
// set back pattern
this.setBackPattern(MaterialNavigationDrawer.BACKPATTERN_LAST_SECTION_FRAGMENT);
}
Aggregations