Search in sources :

Example 11 with TabFragment

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();
    }
}
Also used : Intent(android.content.Intent) TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment)

Aggregations

TabFragment (forpdateam.ru.forpda.ui.fragments.TabFragment)11 Intent (android.content.Intent)2 FavoritesFragment (forpdateam.ru.forpda.ui.fragments.favorites.FavoritesFragment)2 ThemeFragment (forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Handler (android.os.Handler)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 View (android.view.View)1 AttachmentItem (forpdateam.ru.forpda.api.theme.editpost.models.AttachmentItem)1 ThemePage (forpdateam.ru.forpda.api.theme.models.ThemePage)1 ErrorHandler (forpdateam.ru.forpda.common.ErrorHandler)1 NetworkStateReceiver (forpdateam.ru.forpda.common.receivers.NetworkStateReceiver)1 SimpleUpdateChecker (forpdateam.ru.forpda.ui.activities.updatechecker.SimpleUpdateChecker)1 AuthFragment (forpdateam.ru.forpda.ui.fragments.auth.AuthFragment)1 TopicsFragment (forpdateam.ru.forpda.ui.fragments.topics.TopicsFragment)1 KeyboardUtil (forpdateam.ru.forpda.ui.views.KeyboardUtil)1 DrawerHeader (forpdateam.ru.forpda.ui.views.drawers.DrawerHeader)1 Drawers (forpdateam.ru.forpda.ui.views.drawers.Drawers)1