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:com.waz.zclient.pages.main.conversation.ConversationManagerFragment.java

@Override
public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) {
    if (!destination.equals(getCurrentPickerDestination())) {
        return;/*from   ww  w  . ja  va2 s .  co  m*/
    }
    if (IPickUserController.Destination.CURSOR.equals(getCurrentPickerDestination())) {
        getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG);
    } else {
        getControllerFactory().getNavigationController().setRightPage(Page.PARTICIPANT, TAG);
    }
    getChildFragmentManager().popBackStack(PickUserFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

From source file:com.waz.zclient.pages.main.conversationlist.ConversationListManagerFragment.java

@Override
public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) {
    if (!destination.equals(getCurrentPickerDestination())) {
        return;//from   www.j  a  va  2  s.c  o  m
    }

    Page page = getControllerFactory().getNavigationController().getCurrentLeftPage();
    switch (page) {
    case SEND_CONNECT_REQUEST:
    case BLOCK_USER:
    case PENDING_CONNECT_REQUEST:
        getControllerFactory().getPickUserController().hideUserProfile();
    case PICK_USER:
        ConversationListFragment conversationListFragment = (ConversationListFragment) getChildFragmentManager()
                .findFragmentByTag(ConversationListFragment.TAG);
        if (conversationListFragment != null) {
            conversationListFragment.setScrollToConversation(!closeWithoutSelectingPeople);
        }

        getChildFragmentManager().popBackStackImmediate(PickUserFragment.TAG,
                FragmentManager.POP_BACK_STACK_INCLUSIVE);

        KeyboardUtils.hideKeyboard(getActivity());
        break;
    }

    getControllerFactory().getNavigationController().setLeftPage(Page.CONVERSATION_LIST, TAG);
    getControllerFactory().getFocusController().setFocus(IFocusController.CONVERSATION_CURSOR);
}

From source file:org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity.java

public void showMainFragment() {
    new Handler().post(new Runnable() {
        @Override/*from   w ww  . j a v a2 s  . co m*/
        public void run() {
            FragmentManager manager = getSupportFragmentManager();

            // unless we must refresh
            ViewKeyFragment frag = (ViewKeyFragment) manager.findFragmentByTag("view_key_fragment");
            // if everything is valid, just drop it
            if (frag != null && frag.isValidForData(mIsSecret)) {
                return;
            }

            // if the main fragment doesn't exist, or is not of the correct type, (re)create it
            frag = ViewKeyFragment.newInstance(mMasterKeyId, mIsSecret);
            // get rid of possible backstack, this fragment is always at the bottom
            manager.popBackStack("security_token", FragmentManager.POP_BACK_STACK_INCLUSIVE);
            manager.beginTransaction().replace(R.id.view_key_fragment, frag, "view_key_fragment")
                    // if this gets lost, it doesn't really matter since the loader will reinstate it onResume
                    .commitAllowingStateLoss();
        }
    });
}

From source file:uk.co.nevarneyok.ux.MainActivity.java

/**
 * Method clear fragment backStack (back history). On bottom of stack will remain Fragment added by {@link #addInitialFragment()}.
 *///from  w  ww . j  a v  a  2  s  . c  o  m
private void clearBackStack() {
    Timber.d("Clearing backStack");
    FragmentManager manager = getSupportFragmentManager();
    if (manager.getBackStackEntryCount() > 0) {
        if (BuildConfig.DEBUG) {
            for (int i = 0; i < manager.getBackStackEntryCount(); i++) {
                Timber.d("BackStack content_%d= id: %d, name: %s", i, manager.getBackStackEntryAt(i).getId(),
                        manager.getBackStackEntryAt(i).getName());
            }
        }
        FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0);
        manager.popBackStackImmediate(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    Timber.d("backStack cleared.");
    //        TODO maybe implement own fragment backStack handling to prevent banner fragment recreation during clearing.
    //        http://stackoverflow.com/questions/12529499/problems-with-android-fragment-back-stack<
}

From source file:com.ovrhere.android.careerstack.ui.MainActivity.java

/** Loads a fragment either by adding or replacing and then adds it to
 * the fragTagList./*from   w  ww  . j a  v  a2 s.c  o  m*/
 * @param fragment The fragment to add
 * @param tag The tag to give the fragment
 * @param backStack <code>true</code> to add to backstack, 
 * <code>false</code> to not.
 */
private void loadFragment(Fragment fragment, String tag, boolean backStack) {

    FragmentManager fragManager = getSupportFragmentManager();

    if (backStack) {
        String prevTag = fragTagStack.peek();
        fragManager.beginTransaction().addToBackStack(prevTag).replace(R.id.container, fragment, tag).commit();
    } else {
        //clear the entire backstack
        fragManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        fragManager.beginTransaction().replace(R.id.container, fragment, tag).commit();
        fragTagStack.clear();
        fragSavedStates.clear();
    }

    fragTagStack.push(tag);

    checkTabletFrag();
    checkMenus();
    checkHomeButtonBack();
}

From source file:org.alfresco.mobile.android.application.fragments.workflow.task.TaskDetailsFragment.java

private void clearFragment() {
    if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.with(getActivity()).remove(TAG);
    } else {/*from w ww. ja va 2s.  c o  m*/
        getFragmentManager().popBackStack(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        ((TasksFragment) getFragmentManager().findFragmentByTag(TasksFragment.TAG)).refresh();
    }
}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarMainActivity.java

private void clearBackStack() {
    if (mFragManager.getBackStackEntryCount() > 0) {
        mFragManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        onSearchExpanded(false);/* w ww . j  av  a  2s.  c  om*/
    }
}

From source file:com.waz.zclient.pages.main.conversation.ConversationManagerFragment.java

@Override
public void onHideShareLocation(MessageContent.Location location) {
    if (location != null) {
        getStoreFactory().getConversationStore().sendMessage(location);
    }// ww w. ja va  2  s  .  co  m
    getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG);
    getStoreFactory().getInAppNotificationStore().setUserSendingPicture(false);
    getChildFragmentManager().popBackStack(LocationFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

From source file:org.gateshipone.odyssey.activities.OdysseyMainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    View coordinatorLayout = findViewById(R.id.main_coordinator_layout);
    coordinatorLayout.setVisibility(View.VISIBLE);

    NowPlayingView nowPlayingView = (NowPlayingView) findViewById(R.id.now_playing_layout);
    if (nowPlayingView != null) {
        nowPlayingView.minimize();/* w  ww . j a  v a 2s.com*/
    }

    FragmentManager fragmentManager = getSupportFragmentManager();

    // clear backstack
    fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

    Fragment fragment = null;

    if (id == R.id.nav_my_music) {
        fragment = new MyMusicFragment();
    } else if (id == R.id.nav_saved_playlists) {
        fragment = new SavedPlaylistsFragment();
    } else if (id == R.id.nav_bookmarks) {
        fragment = new BookmarksFragment();
    } else if (id == R.id.nav_files) {
        fragment = new FilesFragment();

        // open the default directory
        List<String> storageVolumesList = mFileExplorerHelper.getStorageVolumes(getApplicationContext());

        String defaultDirectory = "/";

        if (!storageVolumesList.isEmpty()) {
            // choose the latest used storage volume as default
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            defaultDirectory = sharedPref.getString(getString(R.string.pref_file_browser_root_dir_key),
                    storageVolumesList.get(0));
        }

        Bundle args = new Bundle();
        args.putString(FilesFragment.ARG_DIRECTORYPATH, defaultDirectory);
        args.putBoolean(FilesFragment.ARG_ISROOTDIRECTORY, storageVolumesList.contains(defaultDirectory));

        fragment.setArguments(args);

    } else if (id == R.id.nav_settings) {
        fragment = new SettingsFragment();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer != null) {
        drawer.closeDrawer(GravityCompat.START);
    }

    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.fragment_container, fragment);
    transaction.commit();

    return true;
}

From source file:com.waz.zclient.pages.main.conversation.ConversationManagerFragment.java

@Override
public void closeLikesList() {
    Fragment fragment = getChildFragmentManager()
            .findFragmentById(R.id.fl__conversation_manager__message_list_container);
    if (fragment instanceof LikesListFragment) {
        getChildFragmentManager().popBackStack(LikesListFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }/*from w ww .j  av  a2s  .com*/
}