List of usage examples for android.app FragmentManager getBackStackEntryCount
public abstract int getBackStackEntryCount();
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * Convenient method to pop to fragment with Given class. * @param guidedStepFragmentClass Name of the Class of GuidedStepFragment to pop to. * @param flags Either 0 or {@link FragmentManager#POP_BACK_STACK_INCLUSIVE}. *//*from w ww .j a v a2 s . c o m*/ public void popBackStackToGuidedStepFragment(Class guidedStepFragmentClass, int flags) { if (!GuidedStepFragment.class.isAssignableFrom(guidedStepFragmentClass)) { return; } final FragmentManager fragmentManager = getFragmentManager(); final int entryCount = fragmentManager.getBackStackEntryCount(); String className = guidedStepFragmentClass.getName(); if (entryCount > 0) { for (int i = entryCount - 1; i >= 0; i--) { BackStackEntry entry = fragmentManager.getBackStackEntryAt(i); String entryClassName = getGuidedStepFragmentClassName(entry.getName()); if (className.equals(entryClassName)) { fragmentManager.popBackStack(entry.getId(), flags); return; } } } }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
private void popBackStack() { FragmentManager mgr = getFragmentManager(); int idxLast = mgr.getBackStackEntryCount() - 2; if (idxLast < 0) { Intent result = new Intent(); // If we are in a WEBKIT, return the instanceId and the savepoint_type... if (this.getInstanceId() != null && currentFragment == ScreenList.WEBKIT) { result.putExtra("instanceId", getInstanceId()); // in this case, the savepoint_type is null (a checkpoint). }/* ww w . j ava2 s . c o m*/ this.setResult(RESULT_OK, result); finish(); } else { BackStackEntry entry = mgr.getBackStackEntryAt(idxLast); swapToFragmentView(ScreenList.valueOf(entry.getName())); } }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
@Override public void onBackPressed() { FragmentManager mgr = getFragmentManager(); int idxLast = mgr.getBackStackEntryCount() - 2; if (idxLast < 0) { Intent result = new Intent(); // If we are in a WEBKIT, return the instanceId and the savepoint_type... if (this.getInstanceId() != null && currentFragment == ScreenList.WEBKIT) { result.putExtra("instanceId", getInstanceId()); // in this case, the savepoint_type is null (a checkpoint). }//from www .ja v a 2 s . c om this.setResult(RESULT_OK, result); finish(); } else { BackStackEntry entry = mgr.getBackStackEntryAt(idxLast); swapToFragmentView(ScreenList.valueOf(entry.getName())); } }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
@SuppressLint("InlinedApi") @Override/*from ww w .j a v a2 s.co m*/ protected void onStart() { super.onStart(); // ensure the DbShimService is started Intent intent = new Intent(this, DbShimService.class); this.startService(intent); this.bindService(intent, mConnection, Context.BIND_AUTO_CREATE | ((Build.VERSION.SDK_INT >= 14) ? Context.BIND_ADJUST_WITH_ACTIVITY : 0)); FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); ODKWebView wkt = (ODKWebView) findViewById(R.id.webkit_view); if (currentFragment == ScreenList.FORM_CHOOSER || currentFragment == ScreenList.FORM_DOWNLOADER || currentFragment == ScreenList.FORM_DELETER || currentFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER || currentFragment == ScreenList.INSTANCE_UPLOADER || currentFragment == ScreenList.INITIALIZATION_DIALOG) { shadow.setVisibility(View.GONE); shadow.removeAllViews(); wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } else if (currentFragment == ScreenList.WEBKIT) { shadow.setVisibility(View.GONE); shadow.removeAllViews(); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); frags.setVisibility(View.GONE); } else if (currentFragment == ScreenList.CUSTOM_VIEW) { shadow.setVisibility(View.VISIBLE); // shadow.removeAllViews(); wkt.setVisibility(View.GONE); frags.setVisibility(View.GONE); } FragmentManager mgr = getFragmentManager(); if (mgr.getBackStackEntryCount() == 0) { swapToFragmentView(currentFragment); } }
From source file:org.path.episample.android.activities.MainMenuActivity.java
@SuppressLint("InlinedApi") @Override//from w w w .j a va 2 s . com protected void onStart() { super.onStart(); // ensure the DbShimService is started Intent intent = new Intent(this, DbShimService.class); this.startService(intent); this.bindService(intent, mConnection, Context.BIND_AUTO_CREATE | ((Build.VERSION.SDK_INT >= 14) ? Context.BIND_ADJUST_WITH_ACTIVITY : 0)); FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); ODKWebView wkt = (ODKWebView) findViewById(R.id.webkit_view); if (currentFragment == ScreenList.MAIN_MENU || currentFragment == ScreenList.COLLECT_MODULE || currentFragment == ScreenList.SEND_RECEIVE_WIFI_DIRECT_MODULE || currentFragment == ScreenList.SEND_RECEIVE_BLUETOOTH_MODULE || currentFragment == ScreenList.SELECT_MODULE || currentFragment == ScreenList.NAVIGATE_MODULE || currentFragment == ScreenList.RESTORE_MODULE || currentFragment == ScreenList.EDIT_CENSUS_MODULE || currentFragment == ScreenList.REMOVE_CENSUS_MODULE || currentFragment == ScreenList.INVALIDATE_CENSUS_MODULE || currentFragment == ScreenList.FORM_CHOOSER || currentFragment == ScreenList.FORM_DOWNLOADER || currentFragment == ScreenList.FORM_DELETER || currentFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER || currentFragment == ScreenList.INSTANCE_UPLOADER || currentFragment == ScreenList.INITIALIZATION_DIALOG) { shadow.setVisibility(View.GONE); shadow.removeAllViews(); wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } else if (currentFragment == ScreenList.WEBKIT) { shadow.setVisibility(View.GONE); shadow.removeAllViews(); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); frags.setVisibility(View.GONE); } else if (currentFragment == ScreenList.CUSTOM_VIEW) { shadow.setVisibility(View.VISIBLE); // shadow.removeAllViews(); wkt.setVisibility(View.GONE); frags.setVisibility(View.GONE); } FragmentManager mgr = getFragmentManager(); if (mgr.getBackStackEntryCount() == 0) { swapToFragmentView(currentFragment); } }
From source file:de.sourcestream.movieDB.MainActivity.java
/** * Pops the last item from the back stack. * If searchView is opened it hides it./*from ww w. java2 s. c o m*/ * reAttachMovieFragments re-creates our fragments this is due to a bug in the viewPager * restoreMovieDetailsState -> when we press back button we would like to restore our previous (if any) * saved state for the current fragment. We use custom backStack since the original doesn't save fragment's state. */ @Override public void onBackPressed() { FragmentManager fm = getFragmentManager(); if (mDrawerLayout.isDrawerOpen(mDrawerList)) mDrawerLayout.closeDrawer(mDrawerList); else { if (searchViewItem.isActionViewExpanded()) searchViewItem.collapseActionView(); else if (fm.getBackStackEntryCount() > 0) { String backStackEntry = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName(); if (backStackEntry.equals("movieList")) reAttachMovieFragments = true; if (backStackEntry.equals("TVList")) reAttachTVFragments = true; if (backStackEntry.equals("searchList:1")) reAttachMovieFragments = true; if (backStackEntry.equals("searchList:2")) reAttachTVFragments = true; restoreMovieDetailsState = true; restoreMovieDetailsAdapterState = false; if (orientationChanged) restoreMovieDetailsAdapterState = true; fm.popBackStack(); } else { super.onBackPressed(); } } }
From source file:de.sourcestream.movieDB.MainActivity.java
/** * First configure the Universal Image Downloader, * then we set the main layout to be activity_main.xml * and we add the slide menu items.//from w ww. j av a 2s . co m * * @param savedInstanceState If non-null, this activity is being re-constructed from a previous saved state as given here. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle(); // load slide menu items navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.list_slidermenu); ViewGroup header = (ViewGroup) getLayoutInflater().inflate(R.layout.drawer_header, null, false); ImageView drawerBackButton = (ImageView) header.findViewById(R.id.drawerBackButton); drawerBackButton.setOnClickListener(onDrawerBackButton); mDrawerList.addHeaderView(header); mDrawerList.setOnItemClickListener(new SlideMenuClickListener()); // setting the nav drawer list adapter mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, R.id.title, navMenuTitles)); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); toolbar.bringToFront(); } mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ toolbar, R.string.app_name, // nav drawer open - description for accessibility R.string.app_name // nav drawer close - description for accessibility ) { public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); // calling onPrepareOptionsMenu() to show search view invalidateOptionsMenu(); syncState(); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); // calling onPrepareOptionsMenu() to hide search view invalidateOptionsMenu(); syncState(); } // updates the title, toolbar transparency and search view public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (slideOffset > .55 && !isDrawerOpen) { // opening drawer // mDrawerTitle is app title getSupportActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); isDrawerOpen = true; } else if (slideOffset < .45 && isDrawerOpen) { // closing drawer // mTitle is title of the current view, can be movies, tv shows or movie title getSupportActionBar().setTitle(mTitle); invalidateOptionsMenu(); isDrawerOpen = false; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // Get the action bar title to set padding TextView titleTextView = null; try { Field f = toolbar.getClass().getDeclaredField("mTitleTextView"); f.setAccessible(true); titleTextView = (TextView) f.get(toolbar); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } if (titleTextView != null) { float scale = getResources().getDisplayMetrics().density; titleTextView.setPadding((int) scale * 15, 0, 0, 0); } phone = getResources().getBoolean(R.bool.portrait_only); searchDB = new SearchDB(getApplicationContext()); if (savedInstanceState == null) { // Check orientation and lock to portrait if we are on phone if (phone) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } // on first time display view for first nav item displayView(1); // Use hockey module to check for updates checkForUpdates(); // Universal Loader options and configuration. DisplayImageOptions options = new DisplayImageOptions.Builder() // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false) .showImageOnLoading(R.drawable.placeholder_default) .showImageForEmptyUri(R.drawable.placeholder_default) .showImageOnFail(R.drawable.placeholder_default).cacheOnDisk(true).build(); Context context = this; File cacheDir = StorageUtils.getCacheDirectory(context); // Create global configuration and initialize ImageLoader with this config ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .diskCache(new UnlimitedDiscCache(cacheDir)) // default .defaultDisplayImageOptions(options).build(); ImageLoader.getInstance().init(config); // Check cache size long size = 0; File[] filesCache = cacheDir.listFiles(); for (File file : filesCache) { size += file.length(); } if (cacheDir.getUsableSpace() < MinFreeSpace || size > CacheSize) { ImageLoader.getInstance().getDiskCache().clear(); searchDB.cleanSuggestionRecords(); } } else { oldPos = savedInstanceState.getInt("oldPos"); currentMovViewPagerPos = savedInstanceState.getInt("currentMovViewPagerPos"); currentTVViewPagerPos = savedInstanceState.getInt("currentTVViewPagerPos"); restoreMovieDetailsState = savedInstanceState.getBoolean("restoreMovieDetailsState"); restoreMovieDetailsAdapterState = savedInstanceState.getBoolean("restoreMovieDetailsAdapterState"); movieDetailsBundle = savedInstanceState.getParcelableArrayList("movieDetailsBundle"); castDetailsBundle = savedInstanceState.getParcelableArrayList("castDetailsBundle"); tvDetailsBundle = savedInstanceState.getParcelableArrayList("tvDetailsBundle"); currOrientation = savedInstanceState.getInt("currOrientation"); lastVisitedSimMovie = savedInstanceState.getInt("lastVisitedSimMovie"); lastVisitedSimTV = savedInstanceState.getInt("lastVisitedSimTV"); lastVisitedMovieInCredits = savedInstanceState.getInt("lastVisitedMovieInCredits"); saveInMovieDetailsSimFragment = savedInstanceState.getBoolean("saveInMovieDetailsSimFragment"); FragmentManager fm = getFragmentManager(); // prevent the following bug: go to gallery preview -> swap orientation -> // go to movies list -> swap orientation -> action bar bugged // so if we are not on gallery preview we show toolbar if (fm.getBackStackEntryCount() == 0 || !fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName().equals("galleryList")) { new Handler().post(new Runnable() { @Override public void run() { if (getSupportActionBar() != null && !getSupportActionBar().isShowing()) getSupportActionBar().show(); } }); } } // Get reference for the imageLoader imageLoader = ImageLoader.getInstance(); // Options used for the backdrop image in movie and tv details and gallery optionsWithFade = new DisplayImageOptions.Builder() // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. .bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(500)) .imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false).showImageOnLoading(R.color.black) .showImageForEmptyUri(R.color.black).showImageOnFail(R.color.black).cacheOnDisk(true).build(); optionsWithoutFade = new DisplayImageOptions.Builder() // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false) .showImageOnLoading(R.color.black).showImageForEmptyUri(R.color.black) .showImageOnFail(R.color.black).cacheOnDisk(true).build(); // Options used for the backdrop image in movie and tv details and gallery backdropOptionsWithFade = new DisplayImageOptions.Builder() // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. .bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(500)) .imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false) .showImageOnLoading(R.drawable.placeholder_backdrop) .showImageForEmptyUri(R.drawable.placeholder_backdrop) .showImageOnFail(R.drawable.placeholder_backdrop).cacheOnDisk(true).build(); backdropOptionsWithoutFade = new DisplayImageOptions.Builder() // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false) .showImageOnLoading(R.drawable.placeholder_backdrop) .showImageForEmptyUri(R.drawable.placeholder_backdrop) .showImageOnFail(R.drawable.placeholder_backdrop).cacheOnDisk(true).build(); trailerListView = new TrailerList(); galleryListView = new GalleryList(); if (currOrientation != getResources().getConfiguration().orientation) orientationChanged = true; currOrientation = getResources().getConfiguration().orientation; iconConstantSpecialCase = 0; if (phone) { iconMarginConstant = 0; iconMarginLandscape = 0; DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); int width = displayMetrics.widthPixels; int height = displayMetrics.heightPixels; if (width <= 480 && height <= 800) iconConstantSpecialCase = -70; // used in MovieDetails, CastDetails, TVDetails onMoreIconClick // to check whether the animation should be in up or down direction threeIcons = 128; threeIconsToolbar = 72; twoIcons = 183; twoIconsToolbar = 127; oneIcon = 238; oneIconToolbar = 182; } else { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { iconMarginConstant = 232; iconMarginLandscape = 300; threeIcons = 361; threeIconsToolbar = 295; twoIcons = 416; twoIconsToolbar = 351; oneIcon = 469; oneIconToolbar = 407; } else { iconMarginConstant = 82; iconMarginLandscape = 0; threeIcons = 209; threeIconsToolbar = 146; twoIcons = 264; twoIconsToolbar = 200; oneIcon = 319; oneIconToolbar = 256; } } dateFormat = android.text.format.DateFormat.getDateFormat(this); }
From source file:co.taqat.call.LinphoneActivity.java
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); /*/* ww w . j a va 2 s .c o m*/ if (!withoutAnimation && currentFragment.shouldAnimate()) { if (newFragmentType.isRightOf(currentFragment)) { transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right); } else { transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left); } }*/ if (newFragmentType != FragmentsAvailable.DIALER && newFragmentType != FragmentsAvailable.CONTACTS_LIST && newFragmentType != FragmentsAvailable.CHAT_LIST && newFragmentType != FragmentsAvailable.HISTORY_LIST) { transaction.addToBackStack(newFragmentType.toString()); } else { while (fm.getBackStackEntryCount() > 0) { fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString()); transaction.commitAllowingStateLoss(); fm.executePendingTransactions(); currentFragment = newFragmentType; }
From source file:it.scoppelletti.mobilepower.app.FragmentLayoutController.java
/** * Ripristina lo stato dell’istanza. * // www . j a v a2 s . c o m * <P>L’attività ripristina lo stato dell’istanza * {@code FragmentLayoutController} all’interno del proprio metodo * {@code onRestoreInstanceState}.</P> * * @param savedInstanceState Stato dell’istanza. * @param fragmentCollector Collettore dei frammenti di dettaglio. */ public void onRestoreInstanceState(Bundle savedInstanceState, FragmentLayoutController.FragmentCollector fragmentCollector) { int n, oldPanelCount, tnId; String tag; ActivitySupport activitySupport; FragmentSupport fragment; FragmentManager fragmentMgr; FragmentLayoutController.BackStackChangedListener backStackListener; Queue<FragmentSupport> fragmentQueue; Queue<FragmentLayoutController.FragmentEntry> clonedQueue; if (savedInstanceState == null) { throw new NullPointerException("Argument savedInstanceState is null."); } if (fragmentCollector == null) { throw new NullPointerException("Argument fragmentCollector is null."); } if (!(myActivity instanceof ActivitySupport)) { myLogger.warn("Activity not implement interface ActivitySupport."); return; } oldPanelCount = savedInstanceState.getInt(FragmentLayoutController.STATE_PANELCOUNT, 0); if (oldPanelCount < 1) { myLogger.warn("Unexpected {}={} in saved instance state.", FragmentLayoutController.STATE_PANELCOUNT, oldPanelCount); return; } myLogger.debug("{}: current={}, saved instance state={}.", new Object[] { FragmentLayoutController.STATE_PANELCOUNT, myFrameCount, oldPanelCount }); if (oldPanelCount == myFrameCount) { // Il numero di pannelli non e' cambiato: // Il sistema ha gia' ripristinato correttamente i frammenti. return; } fragmentQueue = new ArrayDeque<FragmentSupport>(); fragmentCollector.collectFragments(fragmentQueue); // Ad ogni frammento associo il tag con il quale è stato // inserito clonedQueue = new ArrayDeque<FragmentLayoutController.FragmentEntry>(); while (!fragmentQueue.isEmpty()) { fragment = fragmentQueue.remove(); if (fragment == null) { myLogger.warn("Ignoring null."); continue; } tag = fragment.asFragment().getTag(); if (StringUtils.isBlank(tag)) { myLogger.warn("Ignoring fragment with empty tag."); continue; } clonedQueue.offer(new FragmentLayoutController.FragmentEntry(fragment.cloneFragment(), tag)); } fragmentQueue = null; // free memory activitySupport = (ActivitySupport) myActivity; fragmentMgr = activitySupport.getSupportFragmentManager(); // Ripristino la configurazione dei frammenti iniziale for (n = fragmentMgr.getBackStackEntryCount(); n > 0; n--) { fragmentMgr.popBackStack(); } if (myFrameCount > 1) { tnId = arrangeFragments(fragmentMgr, clonedQueue); } else { tnId = arrangePanel(fragmentMgr, clonedQueue); } if (Build.VERSION.SDK_INT < BuildCompat.VERSION_CODES.HONEYCOMB) { return; } // - Android 4.1.2 // La barra delle azioni non e' correttamente aggiornata forse perche' // si assume che non ce ne sia bisogno con transazioni schedulate // durante il ripristino dell'attivita' (o magari perche' non e' proprio // previsto che si schedulino transazioni durante il ripristino // dell'attivita'): // Visto che l'esecuzione delle transazioni e' asincrona, devo // utilizzare un gestore degli eventi di modifica del back stack che // gestisca l’ultima transazione che ho schedulato. backStackListener = new FragmentLayoutController.BackStackChangedListener(myActivity, fragmentMgr, tnId); fragmentMgr.addOnBackStackChangedListener(backStackListener); }
From source file:com.lgallardo.youtorrentcontroller.RefreshListener.java
@Override public void onResume() { super.onResume(); activityIsVisible = true;// w w w . j a v a2 s. c om // Handle Item list empty due to Fragment stack try { FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.one_frame && fm.findFragmentById( R.id.one_frame) instanceof com.lgallardo.youtorrentcontroller.ItemstFragment) { com.lgallardo.youtorrentcontroller.ItemstFragment fragment = (com.lgallardo.youtorrentcontroller.ItemstFragment) fm .findFragmentById(R.id.one_frame); if (fragment.getListView().getCount() == 0) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.one_frame, aboutFragment, "firstFragment"); fragmentTransaction.commit(); // Se titile // setTitle(navigationDrawerItemTitles[drawerList.getCheckedItemPosition()]); setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.content_frame && (fm.findFragmentByTag("secondFragment") instanceof AboutFragment)) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.content_frame, aboutFragment, "secondFragment"); fragmentTransaction.commit(); // Set title setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } catch (Exception e) { } }