Example usage for android.app FragmentManager POP_BACK_STACK_INCLUSIVE

List of usage examples for android.app FragmentManager POP_BACK_STACK_INCLUSIVE

Introduction

In this page you can find the example usage for android.app FragmentManager POP_BACK_STACK_INCLUSIVE.

Prototype

int POP_BACK_STACK_INCLUSIVE

To view the source code for android.app FragmentManager POP_BACK_STACK_INCLUSIVE.

Click Source Link

Document

Flag for #popBackStack(String,int) and #popBackStack(int,int) : If set, and the name or ID of a back stack entry has been supplied, then all matching entries will be consumed until one that doesn't match is found or the bottom of the stack is reached.

Usage

From source file:com.notriddle.budget.EnvelopesActivity.java

public void topFragment(Class<?> cls, int transition, Bundle args) {
    Fragment frag = Fragment.instantiate(this, cls.getName(), args);
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    fragmentManager.beginTransaction().replace(R.id.content_frame, frag).setTransition(transition).commit();
    fragmentManager.executePendingTransactions();
    configureFragment(frag);/* w  w  w.j  a va  2  s. com*/
}

From source file:edu.scranton.fisherc5.busybusy.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    FragmentManager fragmentManager = getFragmentManager();

    if (fragmentManager.findFragmentByTag("PRE_COMPARE") != null) {
        fragmentManager.popBackStack("PRE_COMPARE_PUSH", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }//  w w  w.j av a  2  s .  c  om

    switch (position) {
    case 0:
        Fragment updateFrag = new UpdateFragment();
        fragmentManager.beginTransaction().replace(R.id.content_frame, updateFrag).commit();
        break;

    case 1:
        Fragment precompareFrag = new PreCompareFragment();
        fragmentManager.beginTransaction().replace(R.id.content_frame, precompareFrag).commit();
        break;

    case 3:
        Fragment updateActivityFrag = new UpdateUserActivityFragment();
        fragmentManager.beginTransaction().replace(R.id.content_frame, updateActivityFrag).commit();
        break;
    }

    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(mNavItems[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.bradbergeron.splitviewcontrollerdemo.activities.MainActivity.java

@Override
public void onDrawerItemSelected(final DrawerFragment.FragmentDrawerItem fragmentDrawerItem) {
    if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
        mDrawerLayout.closeDrawer(Gravity.START);
    }/* w  w w  .  j ava  2  s .co m*/

    final FragmentManager fragmentManager = getFragmentManager();
    final String fragmentClassName = fragmentDrawerItem.getFragmentClass().getName();

    Fragment newFragment = fragmentManager.findFragmentByTag(fragmentClassName);

    if (newFragment == null) {
        newFragment = Fragment.instantiate(this, fragmentClassName);
    } else if (newFragment.isAdded()) {
        return;
    } else if (fragmentDrawerItem.isDefaultItem() && fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack("Drawer", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }

    final FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.content, newFragment, fragmentClassName);

    if (!fragmentDrawerItem.isDefaultItem()) {
        transaction.addToBackStack("Drawer");
    }

    transaction.commit();
}

From source file:com.sage42.androidappaddicts.app.main.MainActivity.java

/**
 * Remove all back stack to avoid missing flow on back pressed.
 *//*from  www  .j  av a2  s. co  m*/
private void clearAllBackStack() {
    final FragmentManager fragmentManager = this.getFragmentManager();

    final int backStackCount = fragmentManager.getBackStackEntryCount();
    for (int i = 0; i < backStackCount; i++) {
        // removing all the stored backstack
        final int backStackId = fragmentManager.getBackStackEntryAt(i).getId();
        fragmentManager.popBackStack(backStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }

}

From source file:io.digibyte.tools.animation.BRAnimator.java

public static void popBackStackTillEntry(Activity app, int entryIndex) {

    if (app.getFragmentManager() == null) {
        return;/*from ww  w. ja v  a2s.c om*/
    }
    if (app.getFragmentManager().getBackStackEntryCount() <= entryIndex) {
        return;
    }
    FragmentManager.BackStackEntry entry = app.getFragmentManager().getBackStackEntryAt(entryIndex);
    if (entry != null) {
        app.getFragmentManager().popBackStackImmediate(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }

}

From source file:com.luorrak.ouroboros.thread.ThreadActivity.java

public void doPositiveClickInternal(String threadNo, String boardName) {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    //clear dialog fragments
    fragmentManager.popBackStack("threadDialog", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    if (!threadNo.equals("0")) {
        threadDepth = threadDepth + 1;/*w  w  w  . j  a va 2  s .c o  m*/
        threadFragment = new ThreadFragment().newInstance(threadNo, boardName);
        fragmentTransaction.replace(R.id.placeholder_card, threadFragment)
                .addToBackStack("threadDepth" + String.valueOf(threadDepth)).commit();
    } else {
        Intent intent = new Intent(this, CatalogActivity.class);
        intent.putExtra(Util.INTENT_BOARD_NAME, boardName);
        startActivity(intent);

    }

}

From source file:com.jainbooks.activitys.DashboardActivity.java

public void selectItem(int position) {
    Fragment fragment = new EBookStoreFragment();

    if (position == 0) {

        boolean isNetworkConnection = Utils.isNetworkAvailable(activity);
        Store store = ((App) getApplication()).getStore();
        if (store != null || isNetworkConnection) {
            fragment = new EBookStoreFragment();

        } else {/* w ww. j av  a  2s.  co  m*/
            fragment = new EBookNetworkHandlerFragment();

        }
    } else if (position == 1) {
        fragment = new EBookMyLibraryFragment();

        /*   Uri uri = Uri.parse("file:///android_asset/and.pdf");
           Intent intent = new Intent(this,MuPDFActivity.class);
           intent.setAction(Intent.ACTION_VIEW);
           intent.setData(uri);
           startActivity(intent);
           return;*/
    } else if (position == 2) {
        fragment = new AccountFragment();
    }

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(mFragmentTitlesTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);

}

From source file:com.sevensales.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    FragmentManager fragmentManager = getFragmentManager();
    //storage.refreshSalesList();
    //Log.d("q",String.valueOf(storage.sales_list.size()));

    //Toast.makeText(this,String.valueOf(getFragmentManager().getBackStackEntryCount()), Toast.LENGTH_LONG).show();getFragmentManager().getBackStackEntryCount();

    if (0 == position) {
        SalesFragment fragment = new SalesFragment();
        fragment.sales = storage.getSalesList();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    }//  ww w.  j  a  v a2 s .c  om

    if (1 == position) {
        ShopsFragment fragment = new ShopsFragment();
        fragment.shops = storage.getShopsList();

        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    }

    if (2 == position) {
        CategoriesFragment fragment = new CategoriesFragment();
        fragment.categories = storage.getCategoriesList();

        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    }

    if (3 == position) {
        SettingsFragment fragment = new SettingsFragment();

        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    }

    if (4 == position) {
        SubscribesFragment fragment = new SubscribesFragment();
        fragment.subscribes_list = storage.getSubscribesList();

        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
    }
    if (5 == position) {
        SalesFragment fragment = new SalesFragment();
        fragment.sales = storage.push_sales_list;
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
    }

    mDrawerList.setItemChecked(position, true);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.jainbooks.activitys.DashboardActivity.java

protected void executePendingTransactions() {
    if (pendingFragment == null) {
        return;//from  ww  w.ja v  a 2s  .c om
    }

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    fragmentManager.beginTransaction().replace(R.id.content_frame, pendingFragment).commit();

    // update selected item and title, then close the drawer
    setTitle(mFragmentTitlesTitles[pendingPosition]);
    mDrawerLayout.closeDrawer(mDrawerList);
    mDrawerList.smoothScrollToPosition(0);

}

From source file:com.android.tv.tuner.setup.TunerSetupActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        FragmentManager manager = getFragmentManager();
        int count = manager.getBackStackEntryCount();
        if (count > 0) {
            String lastTag = manager.getBackStackEntryAt(count - 1).getName();
            if (ScanResultFragment.class.getCanonicalName().equals(lastTag) && count >= 2) {
                // Pops fragment including ScanFragment.
                manager.popBackStack(manager.getBackStackEntryAt(count - 2).getName(),
                        FragmentManager.POP_BACK_STACK_INCLUSIVE);
                return true;
            } else if (ScanFragment.class.getCanonicalName().equals(lastTag)) {
                mLastScanFragment.finishScan(true);
                return true;
            }//  w w  w.  ja v  a  2  s  . co  m
        }
    }
    return super.onKeyUp(keyCode, event);
}