use of de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener in project AdvancedMaterialDrawer by madcyph3r.
the class ActionBarOwnFontActivity method init.
@Override
public void init(Bundle savedInstanceState) {
drawer = this;
drawer.setSectionChangeListener(new MaterialSectionChangeListener() {
@Override
public void onBeforeChangeSection(MaterialItemSection newSection) {
}
@Override
public void onAfterChangeSection(MaterialItemSection newSection) {
setActionBarTitle(getCurrentSectionFragment().getTitle());
}
});
// information text for the fragment
Bundle bundle = new Bundle();
bundle.putString("instruction", "See the actionbar, it has a custom title with a custom font.");
Fragment fragmentInstruction = new FragmentInstruction();
fragmentInstruction.setArguments(bundle);
// create menu
MaterialMenu menu = new MaterialMenu();
menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Actionbar Own Front"));
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"));
// load menu
this.loadMenu(menu);
// load the MaterialItemSectionFragment, from the given startIndex
this.loadStartFragmentFromMenu(menu);
}
use of de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener in project AdvancedMaterialDrawer by madcyph3r.
the class MaterialItemSection method onClick.
@Override
public void onClick(View v) {
if (sectionListener != null) {
final MaterialItemSection section = this;
MaterialSectionChangeListener sectionChangeListener = drawer.getSectionChangeListener();
if (sectionChangeListener != null)
sectionChangeListener.onBeforeChangeSection(this);
sectionListener.onClick(section, v);
if (sectionChangeListener != null)
sectionChangeListener.onAfterChangeSection(this);
}
}
use of de.madcyph3r.materialnavigationdrawer.listener.MaterialSectionChangeListener in project AdvancedMaterialDrawer by madcyph3r.
the class SectionChangeListenerActivity method init.
@Override
public void init(Bundle savedInstanceState) {
drawer = this;
drawer.setSectionChangeListener(new MaterialSectionChangeListener() {
@Override
public void onBeforeChangeSection(MaterialItemSection newSection) {
// save the current menu, before change. needed for onAfterChangeSection
tmpSection = getCurrentSectionFragment();
if (getCurrentSectionFragment() != newSection) {
Toast.makeText(drawer, "before change section", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onAfterChangeSection(MaterialItemSection newSection) {
// check, if the section really changed
if (getCurrentSectionFragment() == newSection && newSection != tmpSection) {
Toast.makeText(drawer, "after change section", Toast.LENGTH_SHORT).show();
}
}
});
// information text for the fragment
Bundle bundle = new Bundle();
bundle.putString("instruction", "Open the drawer and choose a section. You will get " + "a before and after change toast message.");
Fragment fragmentInstruction = new FragmentInstruction();
fragmentInstruction.setArguments(bundle);
// create menu
MaterialMenu menu = new MaterialMenu();
menu.add(new MaterialItemSectionFragment(this, "Instruction", fragmentInstruction, "Section 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"));
// load menu
this.loadMenu(menu);
// load the MaterialItemSectionFragment, from the given startIndex
this.loadStartFragmentFromMenu(menu);
}
Aggregations