Example usage for android.app FragmentManager popBackStackImmediate

List of usage examples for android.app FragmentManager popBackStackImmediate

Introduction

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

Prototype

public abstract boolean popBackStackImmediate();

Source Link

Document

Like #popBackStack() , but performs the operation immediately inside of the call.

Usage

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

@Override
public void onBackPressed() {
    if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
        mDrawerLayout.closeDrawer(Gravity.START);

        return;//from ww  w  .  j a  v  a  2  s.  co  m
    }

    final FragmentManager fragmentManager = getFragmentManager();

    if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStackImmediate();

        return;
    }

    super.onBackPressed();
}

From source file:org.steveleach.scoresheet.ui.ScoresheetActivity.java

public void closeLatestFragment() {
    FragmentManager fm = getFragmentManager();
    if (fm.getBackStackEntryCount() > 0) {
        fm.popBackStackImmediate();
    }/*from   ww w .j av a2s . com*/
}

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

@Override
public void onBackPressed() {
    FragmentManager fragmentManager = getFragmentManager();
    if (mDrawerLayout.isDrawerOpen(mNavDrawer)) {
        mDrawerLayout.closeDrawers();// w w w.  j a v a 2  s . c o m
    } else if (fragmentManager.getBackStackEntryCount() != 0) {
        fragmentManager.popBackStackImmediate();
        configureFragment(fragmentManager.findFragmentById(R.id.content_frame));
    } else {
        super.onBackPressed();
    }
}

From source file:de.jadehs.jadehsnavigator.MainActivity.java

@Override
public void onBackPressed() {
    FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager.getBackStackEntryCount() > 1) {
        // jump to previous fragment
        fragmentManager.popBackStackImmediate();
        FragmentManager.BackStackEntry entry = fragmentManager
                .getBackStackEntryAt(fragmentManager.getBackStackEntryCount() - 1);
        setTitle(entry.getName());/*w  w w.  java  2s .  co  m*/
    } else {
        // quit the app
        super.onBackPressed();
    }
}

From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java

@Override
public void onBackPressed() {
    //Pop any Fragments if they exist in the navigation stack.
    final FragmentManager manager = getFragmentManager();
    if (manager.getBackStackEntryCount() > 0) {
        manager.popBackStackImmediate();
        return;//  ww w  .  ja  v a 2 s  .c  om
    }
    super.onBackPressed();
}

From source file:eu.focusnet.app.ui.activity.ProjectsListingActivity.java

/**
 * Listener for the back button. We have 2 menu entries in the drawer menu that load their
 * fragment in the main content container.
 * <p/>//w  w w  . jav a  2s  .c  o  m
 * In {@link #getOnClickDrawerItemListener()}, we make sure we do not reload the same page
 * indefinitely such that the below logic can work.
 */
@Override
public void onBackPressed() {
    //Navigate back to the last Fragment or exit the application
    FragmentManager fragmentManager = getFragmentManager();
    // If we have more than one fragments in the stack remove the last inserted
    // This is the case where we move from Bookmarks back to the home page via the BACK button
    if (fragmentManager.getBackStackEntryCount() > 1) {
        //remove the last inserted fragment from the stack
        fragmentManager.popBackStackImmediate();

        // hard coded things is ok as we are only playing with 2 possible targets, and
        // hence hitting the BACK button will always make us go back to the home page
        // (if we hit the BACK button on the home page, we exit the app)
        this.actionBar.setTitle(R.string.project_listing_title);
        highlightSelectedMenuItem(Constant.Navigation.UI_MENU_ENTRY_PROJECTS_LISTING);

        // close the drawer
        this.drawerLayout.closeDrawer(this.drawerListMenu);
    } else {
        // Exit the application
        super.onBackPressed();
    }
}