Example usage for android.support.v4.app FragmentManager POP_BACK_STACK_INCLUSIVE

List of usage examples for android.support.v4.app FragmentManager POP_BACK_STACK_INCLUSIVE

Introduction

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

Prototype

int POP_BACK_STACK_INCLUSIVE

To view the source code for android.support.v4.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:Main.java

public static void clearBackStack(FragmentManager manager) {
    for (int i = 0; i < manager.getBackStackEntryCount(); ++i) {
        manager.popBackStackImmediate();
    }//from w  w w  . java  2  s.  co m

    if (manager.getBackStackEntryCount() > 0) {
        manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
}

From source file:Main.java

private static void popFragmentView(FragmentManager fm, boolean immediate) {
    if (fm == null)
        return;//w w w. j a v a2  s . c o  m
    int flags = FragmentManager.POP_BACK_STACK_INCLUSIVE;
    if (immediate) {
        fm.popBackStackImmediate(null, flags);
    } else {
        fm.popBackStack(null, flags);
    }
}

From source file:Main.java

/**
 * This method clears backstack and loads fragment in a root.
 * /*from   ww w.j a v  a  2  s  . c o m*/
 * @param fragmentActivity
 * @param fragmentContainerId
 * @param fragmentClass
 * @param bundle
 * @param tag
 * @return true if loaded successfully, false otherwise
 */
public static boolean loadFragmentInRoot(FragmentActivity fragmentActivity, int fragmentContainerId,
        Class<? extends Fragment> fragmentClass, Bundle bundle, String tag) {
    // TODO Auto-generated method stub
    boolean status = false;

    FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();
    // remove all fragments from back stack
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    // add new fragment
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
            android.R.anim.fade_in, android.R.anim.fade_out);
    Fragment fragment;
    try {
        fragment = fragmentClass.newInstance();
        fragment.setArguments(bundle);
        fragmentTransaction.replace(fragmentContainerId, fragment, tag).commit();
        // finish pending transactions
        fragmentManager.executePendingTransactions();
        status = true;
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return status;
}

From source file:org.alfresco.mobile.android.platform.utils.SessionUtils.java

public static void checkSession(FragmentActivity activity, AlfrescoSession alfSession) {
    if (alfSession == null) {
        activity.getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }/*from   www. j  a va  2s. com*/
}

From source file:pedroscott.com.popularmoviesapp.app.ui.base.BaseActivity.java

/**
 * clean Fragment Stack in the FragmentManager.
 *//*from ww  w .java 2s.  com*/
public static void cleanFragmentStack(FragmentManager fm) {
    fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

From source file:com.oursaviorgames.android.ui.AboutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        boolean xwalkPopped = getSupportFragmentManager().popBackStackImmediate("xwalk",
                FragmentManager.POP_BACK_STACK_INCLUSIVE);
        if (xwalkPopped)
            return true;
    }/*  w w  w  .  j  a  v a 2s  . com*/
    return super.onOptionsItemSelected(item);
}

From source file:com.chess.genesis.activity.GameListFrag.java

protected void loadGame(final Bundle gamedata) {
    if (isTablet) {
        final boolean isOnline = gamedata.containsKey("gameid");
        final int gametype = Integer.parseInt(gamedata.getString("gametype"));
        final MenuBarFrag gameMenu = new MenuBarFrag();
        final BoardNavFrag gameNav = new BoardNavFrag();
        final GameFrag gameFrag = (gametype == Enums.GENESIS_CHESS) ? new GenGameFrag() : new RegGameFrag();
        gameFrag.setArguments(gamedata);
        gameFrag.setMenuBarFrag(gameMenu);

        // Pop game if already loaded
        fragMan.popBackStack(gameFrag.getBTag(), FragmentManager.POP_BACK_STACK_INCLUSIVE);

        FragmentTransaction ftrans = fragMan.beginTransaction()
                .replace(R.id.topbar02, gameMenu, gameMenu.getBTag())
                .replace(R.id.botbar02, gameNav, gameNav.getBTag())
                .replace(R.id.panel02, gameFrag, gameFrag.getBTag());

        // setup chat window
        if (isOnline) {
            final MenuBarFrag msgMenu = new MenuBarFrag();
            final BaseContentFrag msgFrag = new MsgBoxFrag();
            msgFrag.setArguments(gamedata);
            msgFrag.setMenuBarFrag(msgMenu);

            ftrans = ftrans.replace(R.id.topbar03, msgMenu, msgMenu.getBTag()).replace(R.id.panel03, msgFrag,
                    msgFrag.getBTag());//www  . jav  a 2s.  c o m
        }
        ftrans.addToBackStack(gameFrag.getBTag()).commit();
    } else {
        final Intent intent = new Intent(act, Game.class);
        intent.putExtras(gamedata);
        startActivity(intent);
    }
}

From source file:com.example.android.supportv13.app.FragmentStackSupport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_stack);

    // Watch for button clicks.
    Button button = (Button) findViewById(R.id.new_fragment);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            addFragmentToStack();/*from ww w .j av a2s .c o  m*/
        }
    });
    button = (Button) findViewById(R.id.home);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // If there is a back stack, pop it all.
            FragmentManager fm = getSupportFragmentManager();
            if (fm.getBackStackEntryCount() > 0) {
                fm.popBackStack(fm.getBackStackEntryAt(0).getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }
        }
    });

    if (savedInstanceState == null) {
        // Do first time initialization -- add initial fragment.
        Fragment newFragment = CountingFragment.newInstance(mStackLevel);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.simple_fragment, newFragment).commit();
    } else {
        mStackLevel = savedInstanceState.getInt("level");
    }
}

From source file:com.ambantis.magic.views.FragmentStackSupport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_stack);

    // Watch for button clicks.
    Button button = (Button) findViewById(R.id.new_fragment);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            addFragmentToStack();/*from w ww .  j  a  va 2  s.co m*/
        }
    });
    button = (Button) findViewById(R.id.home);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // If there is a back stack, pop it all.
            FragmentManager fm = getSupportFragmentManager();
            if (fm.getBackStackEntryCount() > 0) {
                fm.popBackStack(fm.getBackStackEntryAt(0).getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }
        }
    });

    if (savedInstanceState == null) {
        // Do first time initialization -- add initial fragment.
        Fragment newFragment = CountingFragment.newInstance(mIndex);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.simple_fragment, newFragment).commit();
    } else {
        mStackLevel = savedInstanceState.getInt("level");
    }
}

From source file:eu.trentorise.smartcampus.jp.helper.processor.DeleteMyItineraryProcessor.java

@Override
public void handleResult(Void result) {
    Toast toast = Toast.makeText(activity, ctx.getString(R.string.toast_deleted, name), Toast.LENGTH_SHORT);
    toast.show();/*  w  ww. ja  v a 2s  .  com*/
    // activity.getSupportFragmentManager().popBackStackImmediate();
    ((SherlockFragmentActivity) activity).getSupportFragmentManager().popBackStack(mTag,
            FragmentManager.POP_BACK_STACK_INCLUSIVE);

}