use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class Drawers method selectMenuItem.
private void selectMenuItem(MenuItems.MenuItem item) {
Log.d(LOG_TAG, "selectMenuItem " + item);
if (item == null)
return;
try {
if (item.getTabClass() == null) {
switch(item.getAction()) {
case MenuItems.ACTION_APP_SETTINGS:
{
activity.startActivity(new Intent(activity, SettingsActivity.class));
break;
}
}
} else {
TabFragment tabFragment = TabManager.get().get(item.getAttachedTabTag());
if (tabFragment == null) {
for (TabFragment fragment : TabManager.get().getFragments()) {
if (fragment.getClass() == item.getTabClass() && fragment.getConfiguration().isMenu()) {
tabFragment = fragment;
break;
}
}
}
if (tabFragment == null) {
tabFragment = item.getTabClass().newInstance();
tabFragment.getConfiguration().setMenu(true);
TabManager.get().add(tabFragment);
item.setAttachedTabTag(tabFragment.getTag());
} else {
TabManager.get().select(tabFragment);
}
if (lastActive != null)
lastActive.setActive(false);
item.setActive(true);
lastActive = item;
menuAdapter.notifyDataSetChanged();
App.get().getPreferences().edit().putString("menu_drawer_last", item.getTabClass().getSimpleName()).apply();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations