use of it.neokree.materialnavigationdrawer.elements.MaterialSection in project MaterialNavigationDrawer by neokree.
the class MaterialNavigationDrawer method onBackPressed.
@Override
public void onBackPressed() {
if (!isCurrentFragmentChild) {
switch(backPattern) {
default:
case BACKPATTERN_BACK_ANYWHERE:
super.onBackPressed();
break;
case BACKPATTERN_BACK_TO_FIRST:
MaterialSection section = sectionList.get(0);
if (currentSection == section)
super.onBackPressed();
else {
section.select();
//onClick(section);
changeToolbarColor(section);
setFragment((Fragment) section.getTargetFragment(), section.getTitle(), (Fragment) currentSection.getTargetFragment());
afterFragmentSetted((Fragment) section.getTargetFragment(), section.getTitle());
syncSectionsState(section);
}
break;
case BACKPATTERN_CUSTOM:
MaterialSection backedSection = backToSection(getCurrentSection());
if (currentSection == backedSection)
super.onBackPressed();
else {
if (backedSection.getTarget() != MaterialSection.TARGET_FRAGMENT) {
throw new RuntimeException("The restored section must have a fragment as target");
}
backedSection.select();
changeToolbarColor(backedSection);
setFragment((Fragment) backedSection.getTargetFragment(), backedSection.getTitle(), (Fragment) currentSection.getTargetFragment());
afterFragmentSetted((Fragment) backedSection.getTargetFragment(), backedSection.getTitle());
syncSectionsState(backedSection);
}
break;
}
} else {
if (childFragmentStack.size() <= 1) {
isCurrentFragmentChild = false;
onBackPressed();
} else {
// reload the child before
Fragment newFragment = childFragmentStack.get(childFragmentStack.size() - 2);
String newTitle = childTitleStack.get(childTitleStack.size() - 2);
// get and remove the last child
Fragment currentFragment = childFragmentStack.remove(childFragmentStack.size() - 1);
childTitleStack.remove(childTitleStack.size() - 1);
setFragment(newFragment, newTitle, currentFragment);
if (childFragmentStack.size() == 1) {
// user comed back to master section
isCurrentFragmentChild = false;
if (!deviceSupportMultiPane())
pulsante.setDrawerIndicatorEnabled(true);
else
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
}
}
use of it.neokree.materialnavigationdrawer.elements.MaterialSection in project MaterialNavigationDrawer by neokree.
the class MaterialNavigationDrawer method newSectionWithRealColor.
public MaterialSection newSectionWithRealColor(String title, Bitmap icon, Fragment target) {
MaterialSection section = new MaterialSection<Fragment>(this, MaterialSection.ICON_24DP, rippleSupport, MaterialSection.TARGET_FRAGMENT);
section.setOnClickListener(this);
section.useRealColor();
section.setIcon(icon);
section.setTitle(title);
section.setTarget(target);
return section;
}
use of it.neokree.materialnavigationdrawer.elements.MaterialSection in project MaterialNavigationDrawer by neokree.
the class MaterialNavigationDrawer method newSectionWithRealColor.
public MaterialSection newSectionWithRealColor(String title, Bitmap icon, Intent target) {
MaterialSection section = new MaterialSection<Fragment>(this, MaterialSection.ICON_24DP, rippleSupport, MaterialSection.TARGET_ACTIVITY);
section.setOnClickListener(this);
section.useRealColor();
section.setIcon(icon);
section.setTitle(title);
section.setTarget(target);
return section;
}
Aggregations