Пример #1
0
 private void clearBackStack() {
   FragmentManager fragmentManager = MainActivity.getInstance().getSupportFragmentManager();
   int count = fragmentManager.getBackStackEntryCount();
   if (count > 0) {
     BackStackEntry entry = fragmentManager.getBackStackEntryAt(0);
     fragmentManager.popBackStack(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
     popAllFragment();
   }
 }
  @Override
  public void onBackStackChanged() {
    mPath = EXTERNAL_BASE_PATH;

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
      BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
      mPath = fragment.getName();
    }

    setTitle(mPath);
  }
Пример #3
0
  public boolean closeFragment() {
    try {
      FragmentManager fragmentManager = MainActivity.getInstance().getSupportFragmentManager();
      int count = fragmentManager.getBackStackEntryCount();
      if (count > 0) {
        BackStackEntry entry = fragmentManager.getBackStackEntryAt(count - 1);

        fragmentManager.popBackStack(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
        popFragment(1);
        return true;
      }
    } catch (Exception e) {
    }

    return false;
  }
Пример #4
0
 private boolean naviMainFragment(String ftag) {
   FragmentManager fragmentManager = MainActivity.getInstance().getSupportFragmentManager();
   int count = fragmentManager.getBackStackEntryCount();
   for (int i = 0; i < count; i++) {
     BackStackEntry entry = fragmentManager.getBackStackEntryAt(i);
     if (entry != null && !TextUtils.isEmpty(ftag) && entry.getName().contains(ftag)) {
       if (i < count - 1) {
         BackStackEntry topEntry = fragmentManager.getBackStackEntryAt(i + 1);
         fragmentManager.popBackStack(topEntry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
         popFragment(fragmentStack.size() - i - 1);
       }
       return true;
     }
   }
   return false;
 }