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

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

Introduction

In this page you can find the example usage for android.support.v4.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.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        for (int i = 0, count = fm.getBackStackEntryCount(); i < count; i++) {
            fm.popBackStackImmediate();
        }/*  w w  w . j  a  v  a  2 s. c o  m*/
    }
    super.onStart();
    final Resources res = getResources();
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT,
            is_large_screen);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            is_large_screen);
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:org.mariotaku.twidere.activity.SearchActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_HOME: {
        final FragmentManager fm = getSupportFragmentManager();
        if (isDualPaneMode()) {
            final int count = fm.getBackStackEntryCount();
            if (count == 0) {
                NavUtils.navigateUpFromSameTask(this);
            } else if (!FragmentManagerTrojan.isStateSaved(fm)) {
                for (int i = 0; i < count; i++) {
                    fm.popBackStackImmediate();
                }/* w  ww .ja v a2  s .  c  om*/
                setSupportProgressBarIndeterminateVisibility(false);
            }
        } else {
            NavUtils.navigateUpFromSameTask(this);
        }
        break;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:de.fahrgemeinschaft.BaseActivity.java

protected void showFragment(Fragment f, String name, int in, int out) {
    setTitle(name);/*  w  ww .j  a v  a  2s  .c  om*/
    FragmentManager fm = getSupportFragmentManager();
    for (int i = fm.getBackStackEntryCount() - 1; i >= 0; i--) {
        if (fm.getBackStackEntryAt(i).getName().equals(name)) {
            for (int j = fm.getBackStackEntryCount() - 1; j > i; j--) {
                fm.popBackStackImmediate();
            }
            return;
        }
    }
    fm.beginTransaction().setCustomAnimations(in, R.anim.do_nix, R.anim.do_nix, out)
            .add(R.id.container, f, name).addToBackStack(name).commit();
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.MapViewFragment.java

/**
 * Initiates a location listener which immediately starts listening for
 * location updates. Gets the current location as well. Then unpacks the
 * bundle passed to the fragment. It then gets the map setup and prepares
 * the min and max latitude and longitude required to display the map
 * properly for calculation. Then finally sets the zoom level
 *///from w w  w.j a v  a 2s.  co m
@Override
public void onStart() {
    super.onStart();

    locationListenerService = new LocationListenerService(getActivity());
    locationListenerService.startListening();

    Bundle args = getArguments();
    Comment topComment = (Comment) args.getParcelable("thread_comment");

    markers = new ArrayList<CustomMarker>();
    replyMarkers = new ArrayList<CustomMarker>();

    setupClusterGroups();

    GeoLocation geoLocation = topComment.getLocation();
    if (geoLocation.getLocation() == null) {
        ErrorDialog.show(getActivity(), "Thread has no location");
        FragmentManager fm = getFragmentManager();
        fm.popBackStackImmediate();
    } else {
        this.setupMap(topComment);
        this.setZoomLevel(topComment.getLocation());
    }
}

From source file:org.comixwall.pffw.MainActivity.java

private void popAllBackStack() {
    // TODO: What is the best way to pop all backstack items?
    // It does NOT help to use a special StackBottom name while adding the first Dashboard to the backstack,
    // then we could pop all items simply by:
    // fm.popBackStackImmediate("StackBottom", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    // But if we add the first Dashboard to the backstack, we get a blank page when the user presses the back button.

    FragmentManager fm = getSupportFragmentManager();
    while (fm.getBackStackEntryCount() > 0) {
        fm.popBackStackImmediate();
    }//from   ww  w  . ja v  a  2  s.c  om
}

From source file:org.mythdroid.fragments.RecListFragment.java

private void showDetails() {

    Fragment rdf = null;//www.  ja  v  a  2 s  .co  m
    FragmentManager fm = getFragmentManager();
    if (fm == null)
        return;

    FragmentTransaction ft = fm.beginTransaction();

    rdf = RecDetailFragment.newInstance(false, false);

    if (dualPane) {
        Fragment existing = fm.findFragmentById(R.id.recdetails);
        if (existing != null && !existing.getClass().equals(RecDetailFragment.class))
            fm.popBackStackImmediate();
        ft.replace(R.id.recdetails, rdf, rdf.getClass().getSimpleName());
    } else {
        ft.replace(R.id.reclistframe, rdf, rdf.getClass().getSimpleName());
        ft.addToBackStack(null);
    }

    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commitAllowingStateLoss();

}

From source file:io.github.meness.easyintro.utils.BackPressImpl.java

@Override
public boolean onBackPressed() {

    if (parentFragment == null)
        return false;

    int childCount = parentFragment.getChildFragmentManager().getBackStackEntryCount();

    if (childCount == 0) {
        // it has no child Fragment
        // can not handle the onBackPressed task by itself
        return false;

    } else {//from w  w  w  .  j  a v a2s .co m
        // get the child Fragment
        FragmentManager childFragmentManager = parentFragment.getChildFragmentManager();
        OnBackPressListener childFragment = (OnBackPressListener) childFragmentManager.getFragments().get(0);

        // propagate onBackPressed method call to the child Fragment
        if (!childFragment.onBackPressed()) {
            // child Fragment was unable to handle the task
            // It could happen when the child Fragment is last last leaf of a chain
            // removing the child Fragment from stack
            childFragmentManager.popBackStackImmediate();

        }

        // either this Fragment or its child handled the task
        // either way we are successful and done here
        return true;
    }
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.HomeActivity.java

@Override
public void onBeforeCommitReplaceFragment(FragmentManager fm, FragmentTransaction ft, Fragment fragment) {
    super.onBeforeCommitReplaceFragment(fm, ft, fragment);
    if (fragment instanceof SessionsFragment) {
        mPauseBackStackWatcher = true;/*  w ww  .j  ava  2s  .  c o  m*/
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStackImmediate();
        }
        mPauseBackStackWatcher = false;
        ft.addToBackStack(null);
    } else if (fragment instanceof SessionDetailFragment) {
        mPauseBackStackWatcher = true;
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStackImmediate();
        }
        mPauseBackStackWatcher = false;
        ft.addToBackStack(null);
    }
}

From source file:r2b.apps.view.base.BaseActivity.java

/***
 * Clear the back stack to its initial state.
 * Normally with the first fragment setted when activity is created firstly.
 *///from ww w  .j a  v  a2  s .co  m
public void clearBackStack() {
    android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();

    while (fragmentManager.getBackStackEntryCount() > INITIAL_BACK_STACK_SIZE) {
        // If you use popBackStack you probably setup an infinite loop.
        fragmentManager.popBackStackImmediate();
    }

}

From source file:pl.openrnd.managers.fragmentsswapper.SingleContainerFragmentSwapper.java

/**
 * Clears fragments back stack removing all fragments from the hierarchy.
 *///from ww  w . j a  va2  s.c  om
public void clearStack() {
    mPopInProgress = true;
    setAnimationEnabled(false);

    FragmentManager fragmentManager = getFragmentManager();
    int entryCount = fragmentManager.getBackStackEntryCount();
    Log.v(TAG, String.format("clearStack()... entries [%d]", entryCount));
    for (int i = 0; i < entryCount; ++i) {
        try {
            fragmentManager.popBackStackImmediate();
        } catch (Exception exc) {
            Log.e(TAG, "clearStack()", exc);
        }
    }

    findCurrentFragment();

    Log.v(TAG, "clearStack()... DONE");
    setAnimationEnabled(true);
    mPopInProgress = false;
}