List of usage examples for android.app FragmentManager POP_BACK_STACK_INCLUSIVE
int POP_BACK_STACK_INCLUSIVE
To view the source code for android.app FragmentManager POP_BACK_STACK_INCLUSIVE.
Click Source Link
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
private void swapSession(AlfrescoAccount currentAccount) { // Change activity state to loading. setSessionState(SESSION_LOADING);// w w w .jav a 2s .com this.currentAccount = currentAccount; if (getFragment(MainMenuFragment.TAG) != null) { ((MainMenuFragment) getFragment(MainMenuFragment.TAG)).displayFavoriteStatut(); ((MainMenuFragment) getFragment(MainMenuFragment.TAG)).hideWorkflowMenu(currentAccount); } if (getFragment(MainMenuFragment.SLIDING_TAG) != null) { ((MainMenuFragment) getFragment(MainMenuFragment.SLIDING_TAG)).displayFavoriteStatut(); ((MainMenuFragment) getFragment(MainMenuFragment.SLIDING_TAG)).hideWorkflowMenu(currentAccount); } // Return to root screen getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); // Display progress setProgressBarIndeterminateVisibility(true); // Add accountName in actionBar UIUtils.displayTitle(this, getString(R.string.app_name)); }
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
@Subscribe public void onAccountLoaded(LoadAccountCompletedEvent event) { // Avoid collision with PublicDispatcherActivity when selecting an // account./*from w ww . j av a 2s. c o m*/ if (event.requestId == null || getCurrentSession() == null) { return; } if (event.requestId == LoadAccountCompletedEvent.SWAP) { swapSession(event.account); } if (fromSessionRequested) { fromSessionRequested = false; } ServiceRegistry registry = getCurrentSession().getServiceRegistry(); ConfigManager config = ConfigManager.getInstance(this); if (!config.hasConfig(getCurrentAccount().getId())) { config.init(getCurrentAccount()); } if (registry instanceof AlfrescoServiceRegistry) { // Check configuration if (((AlfrescoServiceRegistry) registry).getConfigService() == null) { // In this case there's no configuration defined on server // We remove any cached configuration ConfigManager.getInstance(this).cleanCache(getCurrentAccount()); } else { config.loadRemote(getCurrentAccount().getId(), ((AlfrescoServiceRegistry) registry).getConfigService()); } } config.setSession(getCurrentAccount().getId(), getCurrentSession()); // Retrieve latest avatar Operator.with(this).load(new AvatarRequest.Builder(getCurrentAccount().getUsername())); if (!isCurrentAccountToLoad(event)) { return; } setSessionState(SESSION_ACTIVE); setProgressBarIndeterminateVisibility(false); UIUtils.displayTitle(this, getString(R.string.app_name), false); // Retrieve Rendition Manager associated to this account RenditionManagerImpl.getInstance(this).setSession(getCurrentSession()); // Remove OAuthFragment if one if (getFragment(AccountOAuthFragment.TAG) != null) { getFragmentManager().popBackStack(AccountOAuthFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); } removeWaitingDialog(); // Used for launching last pressed action button from main menu if (fragmentQueue != -1) { doMainMenuAction(fragmentQueue); } fragmentQueue = -1; // Save latest position as default future one AccountsPreferences.setDefaultAccount(this, currentAccount.getId()); // Check Last cloud session creation ==> prevent oauth token // expiration if (getCurrentSession() instanceof CloudSession) { AccountOAuthHelper.saveLastCloudLoadingTime(this); } else { AccountOAuthHelper.removeLastCloudLoadingTime(this); } // NB : temporary code ? // Check to see if we have an old AlfrescoAccount that needs its paid // network flag setting. if (!currentAccount.getIsPaidAccount()) { boolean paidNetwork = false; if (getCurrentSession() instanceof CloudSession) { paidNetwork = ((CloudSession) getCurrentSession()).getNetwork().isPaidNetwork(); } else { paidNetwork = getCurrentSession().getRepositoryInfo().getEdition() .equals(OnPremiseConstant.ALFRESCO_EDITION_ENTERPRISE); } if (paidNetwork) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean(GeneralPreferences.HAS_ACCESSED_PAID_SERVICES, true).commit(); if (mdmManager.hasConfig()) { // TODO Do we want to provide different behaviours in case // of MDM ? } else { DataProtectionUserDialogFragment.newInstance(true).show(getFragmentManager(), DataProtectionUserDialogFragment.TAG); } currentAccount = AlfrescoAccountManager.getInstance(this).update(currentAccount.getId(), currentAccount.getTitle(), currentAccount.getUrl(), currentAccount.getUsername(), currentAccount.getPassword(), currentAccount.getRepositoryId(), currentAccount.getTypeId(), currentAccount.getActivation(), currentAccount.getAccessToken(), currentAccount.getRefreshToken(), 1); } } // Start Sync if active if (FavoritesSyncManager.getInstance(this).hasDisplayedActivateSync(currentAccount)) { FavoritesSyncManager.getInstance(this).sync(currentAccount); } invalidateOptionsMenu(); }
From source file:android.support.v17.leanback.app.BrowseFragment.java
private void startHeadersTransitionInternal(final boolean withHeaders) { if (getFragmentManager().isDestroyed()) { return;//from w ww. j a v a 2s. c o m } if (!isHeadersDataReady()) { return; } mShowingHeaders = withHeaders; mMainFragmentAdapter.onTransitionPrepare(); mMainFragmentAdapter.onTransitionStart(); onExpandTransitionStart(!withHeaders, new Runnable() { @Override public void run() { mHeadersFragment.onTransitionPrepare(); mHeadersFragment.onTransitionStart(); createHeadersTransition(); if (mBrowseTransitionListener != null) { mBrowseTransitionListener.onHeadersTransitionStart(withHeaders); } TransitionHelper.runTransition(withHeaders ? mSceneWithHeaders : mSceneWithoutHeaders, mHeadersTransition); if (mHeadersBackStackEnabled) { if (!withHeaders) { getFragmentManager().beginTransaction().addToBackStack(mWithHeadersBackStackName).commit(); } else { int index = mBackStackChangedListener.mIndexOfHeadersBackStack; if (index >= 0) { BackStackEntry entry = getFragmentManager().getBackStackEntryAt(index); getFragmentManager().popBackStackImmediate(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } } } } }); }
From source file:com.rbware.github.androidcouchpotato.app.BrowseFragment.java
void startHeadersTransitionInternal(final boolean withHeaders) { if (getFragmentManager().isDestroyed()) { return;/* w w w .j ava 2 s .c om*/ } if (!isHeadersDataReady()) { return; } mShowingHeaders = withHeaders; mMainFragmentAdapter.onTransitionPrepare(); mMainFragmentAdapter.onTransitionStart(); onExpandTransitionStart(!withHeaders, new Runnable() { @Override public void run() { mHeadersFragment.onTransitionPrepare(); mHeadersFragment.onTransitionStart(); createHeadersTransition(); if (mBrowseTransitionListener != null) { mBrowseTransitionListener.onHeadersTransitionStart(withHeaders); } TransitionHelper.runTransition(withHeaders ? mSceneWithHeaders : mSceneWithoutHeaders, mHeadersTransition); if (mHeadersBackStackEnabled) { if (!withHeaders) { getFragmentManager().beginTransaction().addToBackStack(mWithHeadersBackStackName).commit(); } else { int index = mBackStackChangedListener.mIndexOfHeadersBackStack; if (index >= 0) { BackStackEntry entry = getFragmentManager().getBackStackEntryAt(index); getFragmentManager().popBackStackImmediate(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } } } } }); }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
@Override public void onNewIntent(Intent intent) { setIntent(intent); // onNewIntent doesn't autoset our "internal" intent removeFragments();//from w w w.ja v a 2s . c o m mUnreadMessageCount = 0; String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT); mAccount = Preferences.getPreferences(this).getAccount(accountUuid); // if (mAccount == null) { // // This shouldn't normally happen. But apparently it does. See issue // 2261. // finish(); // return; // } if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) && !K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) { onOpenFolder(mAccount.getAutoExpandFolderName()); finish(); } else { initializeActivityView(); } if (mFirstBackStackId >= 0) { getFragmentManager().popBackStackImmediate(mFirstBackStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE); mFirstBackStackId = -1; } removeMessageListFragment(); removeMessageViewFragment(); mMessageReference = null; mSearch = null; mFolderName = null; if (!decodeExtras(intent)) { return; } initializeDisplayMode(null); initializeFragments(); displayViews(); refresh(); }
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * Convenient method to close GuidedStepFragments on top of other content or finish Activity if * GuidedStepFragments were started in a separate activity. Pops all stack entries including * {@link #UI_STYLE_ENTRANCE}; if {@link #UI_STYLE_ENTRANCE} is not found, finish the activity. * Note that this method must be paired with {@link #add(FragmentManager, GuidedStepFragment, * int)} which sets up the stack entry name for finding which fragment we need to pop back to. *///from w w w . ja v a2 s .co m public void finishGuidedStepFragments() { final FragmentManager fragmentManager = getFragmentManager(); final int entryCount = fragmentManager.getBackStackEntryCount(); if (entryCount > 0) { for (int i = entryCount - 1; i >= 0; i--) { BackStackEntry entry = fragmentManager.getBackStackEntryAt(i); if (isStackEntryUiStyleEntrance(entry.getName())) { GuidedStepFragment top = getCurrentGuidedStepFragment(fragmentManager); if (top != null) { top.setUiStyle(UI_STYLE_ENTRANCE); } fragmentManager.popBackStack(entry.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); return; } } } ActivityCompat.finishAfterTransition(getActivity()); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void popBackStackFull() { runOnUiThread(new Runnable() { @Override//ww w.ja v a 2 s .c o m public void run() { if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(fm.getBackStackEntryAt(0).getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } refreshActionBarAndTitle(); } }); }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
public void swapToFragmentView(ScreenList newFragment) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView: " + newFragment.toString()); FragmentManager mgr = getFragmentManager(); Fragment f;//ww w .j a va 2s. co m if (newFragment == ScreenList.MAIN_SCREEN) { throw new IllegalStateException("unexpected reference to generic main screen"); } else if (newFragment == ScreenList.CUSTOM_VIEW) { WebLogger.getLogger(getAppName()).w(t, "swapToFragmentView: changing navigation to move to WebKit (was custom view)"); f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } newFragment = ScreenList.WEBKIT; } else if (newFragment == ScreenList.FORM_CHOOSER) { f = mgr.findFragmentById(FormChooserListFragment.ID); if (f == null) { f = new FormChooserListFragment(); } } else if (newFragment == ScreenList.INITIALIZATION_DIALOG) { if (currentFragment == ScreenList.INITIALIZATION_DIALOG) { WebLogger.getLogger(getAppName()).e(t, "Unexpected: currentFragment == INITIALIZATION_DIALOG"); return; } else { f = mgr.findFragmentById(InitializationFragment.ID); if (f == null) { f = new InitializationFragment(); } ((InitializationFragment) f).setFragmentToShowNext( (currentFragment == null) ? ScreenList.FORM_CHOOSER.name() : currentFragment.name()); } } else if (newFragment == ScreenList.FORM_DELETER) { f = mgr.findFragmentById(FormDeleteListFragment.ID); if (f == null) { f = new FormDeleteListFragment(); } } else if (newFragment == ScreenList.FORM_DOWNLOADER) { f = mgr.findFragmentById(FormDownloadListFragment.ID); if (f == null) { f = new FormDownloadListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER) { f = mgr.findFragmentById(InstanceUploaderTableChooserListFragment.ID); if (f == null) { f = new InstanceUploaderTableChooserListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER) { f = mgr.findFragmentById(InstanceUploaderListFragment.ID); if (f == null) { f = new InstanceUploaderListFragment(); } ((InstanceUploaderListFragment) f).changeUploadTableId(); } else if (newFragment == ScreenList.WEBKIT) { f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } } else if (newFragment == ScreenList.ABOUT_MENU) { f = mgr.findFragmentById(AboutMenuFragment.ID); if (f == null) { f = new AboutMenuFragment(); } } else { throw new IllegalStateException("Unrecognized ScreenList type"); } FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); View wkt = findViewById(R.id.webkit_view); shadow.setVisibility(View.GONE); shadow.removeAllViews(); if (newFragment == ScreenList.WEBKIT) { frags.setVisibility(View.GONE); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); } else { wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } currentFragment = newFragment; BackStackEntry entry = null; for (int i = 0; i < mgr.getBackStackEntryCount(); ++i) { BackStackEntry e = mgr.getBackStackEntryAt(i); if (e.getName().equals(currentFragment.name())) { entry = e; break; } } if (entry != null) { // flush backward, including the screen want to go back to mgr.popBackStackImmediate(currentFragment.name(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } // add transaction to show the screen we want FragmentTransaction trans = mgr.beginTransaction(); trans.replace(R.id.main_content, f); trans.addToBackStack(currentFragment.name()); trans.commit(); // and see if we should re-initialize... if ((currentFragment != ScreenList.INITIALIZATION_DIALOG) && Survey.getInstance().shouldRunInitializationTask(getAppName())) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView -- calling clearRunInitializationTask"); // and immediately clear the should-run flag... Survey.getInstance().clearRunInitializationTask(getAppName()); // OK we should swap to the InitializationFragment view swapToFragmentView(ScreenList.INITIALIZATION_DIALOG); } else { levelSafeInvalidateOptionsMenu(); } }
From source file:org.path.episample.android.activities.MainMenuActivity.java
public void swapToFragmentView(ScreenList newFragment) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView: " + newFragment.toString()); String get = PropertiesSingleton.getProperty("survey", AdminPreferencesActivity.KEY_TURN_ON_OFF_WIFI_AUTOMATICALLY); if (!(get != null && get.equalsIgnoreCase("false"))) { if (mWifiManager.isWifiEnabled() && mWifiManager.getWifiState() != WifiManager.WIFI_STATE_DISABLED) { mWifiManager.setWifiEnabled(false); }//from www. jav a 2s . c o m } FragmentManager mgr = getFragmentManager(); Fragment f; if (newFragment == ScreenList.MAIN_SCREEN) { throw new IllegalStateException("unexpected reference to generic main screen"); } else if (newFragment == ScreenList.CUSTOM_VIEW) { WebLogger.getLogger(getAppName()).w(t, "swapToFragmentView: changing navigation to move to WebKit (was custom view)"); f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } newFragment = ScreenList.WEBKIT; } else if (newFragment == ScreenList.MAIN_MENU) { f = mgr.findFragmentById(MainMenuFragment.ID); if (f == null) { f = new MainMenuFragment(); } } else if (newFragment == ScreenList.COLLECT_MODULE) { f = mgr.findFragmentById(CollectFragment.ID); if (f == null) { f = new CollectFragment(); } } else if (newFragment == ScreenList.SEND_RECEIVE_WIFI_DIRECT_MODULE) { f = mgr.findFragmentById(SendReceiveFragment.ID); if (f == null) { f = new SendReceiveFragment(); } } /*else if (newFragment == ScreenList.SEND_RECEIVE_BLUETOOTH_MODULE) { f = mgr.findFragmentById(SendReceiveFragmentBT.ID); if (f == null) { f = new SendReceiveFragmentBT(); } }*/ else if (newFragment == ScreenList.SELECT_MODULE) { f = mgr.findFragmentById(SelectFragment.ID); if (f == null) { f = new SelectFragment(); } } else if (newFragment == ScreenList.NAVIGATE_MODULE) { f = mgr.findFragmentById(NavigateFragment.ID); if (f == null) { f = new NavigateFragment(); } } else if (newFragment == ScreenList.RESTORE_MODULE) { f = mgr.findFragmentById(RestoreFragment.ID); if (f == null) { f = new RestoreFragment(); } } else if (newFragment == ScreenList.EDIT_CENSUS_MODULE) { f = mgr.findFragmentById(EditCensusFragment.ID); if (f == null) { f = new EditCensusFragment(); } } else if (newFragment == ScreenList.REMOVE_CENSUS_MODULE) { f = mgr.findFragmentById(RemoveCensusFragment.ID); if (f == null) { f = new RemoveCensusFragment(); } } else if (newFragment == ScreenList.INVALIDATE_CENSUS_MODULE) { f = mgr.findFragmentById(InvalidateCensusFragment.ID); if (f == null) { f = new InvalidateCensusFragment(); } } else if (newFragment == ScreenList.FORM_CHOOSER) { f = mgr.findFragmentById(FormChooserListFragment.ID); if (f == null) { f = new FormChooserListFragment(); } } else if (newFragment == ScreenList.INITIALIZATION_DIALOG) { if (currentFragment == ScreenList.INITIALIZATION_DIALOG) { WebLogger.getLogger(getAppName()).e(t, "Unexpected: currentFragment == INITIALIZATION_DIALOG"); return; } else { f = mgr.findFragmentById(InitializationFragment.ID); if (f == null) { f = new InitializationFragment(); } ((InitializationFragment) f).setFragmentToShowNext( (currentFragment == null) ? ScreenList.FORM_CHOOSER.name() : currentFragment.name()); } } else if (newFragment == ScreenList.FORM_DELETER) { f = mgr.findFragmentById(FormDeleteListFragment.ID); if (f == null) { f = new FormDeleteListFragment(); } } else if (newFragment == ScreenList.FORM_DOWNLOADER) { f = mgr.findFragmentById(FormDownloadListFragment.ID); if (f == null) { f = new FormDownloadListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER) { f = mgr.findFragmentById(InstanceUploaderTableChooserListFragment.ID); if (f == null) { f = new InstanceUploaderTableChooserListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER) { f = mgr.findFragmentById(InstanceUploaderListFragment.ID); if (f == null) { f = new InstanceUploaderListFragment(); } ((InstanceUploaderListFragment) f).changeUploadTableId(); } else if (newFragment == ScreenList.WEBKIT) { f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } } else if (newFragment == ScreenList.ABOUT_MENU) { f = mgr.findFragmentById(AboutMenuFragment.ID); if (f == null) { f = new AboutMenuFragment(); } } else { throw new IllegalStateException("Unrecognized ScreenList type"); } FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); View wkt = findViewById(R.id.webkit_view); shadow.setVisibility(View.GONE); shadow.removeAllViews(); if (newFragment == ScreenList.WEBKIT) { frags.setVisibility(View.GONE); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); } else { wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } currentFragment = newFragment; BackStackEntry entry = null; for (int i = 0; i < mgr.getBackStackEntryCount(); ++i) { BackStackEntry e = mgr.getBackStackEntryAt(i); if (e.getName().equals(currentFragment.name())) { entry = e; break; } } if (entry != null) { // flush backward, including the screen want to go back to mgr.popBackStackImmediate(currentFragment.name(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } // add transaction to show the screen we want FragmentTransaction trans = mgr.beginTransaction(); trans.replace(R.id.main_content, f); trans.addToBackStack(currentFragment.name()); trans.commit(); // and see if we should re-initialize... if ((currentFragment != ScreenList.INITIALIZATION_DIALOG) && Survey.getInstance().shouldRunInitializationTask(getAppName())) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView -- calling clearRunInitializationTask"); // and immediately clear the should-run flag... Survey.getInstance().clearRunInitializationTask(getAppName()); // OK we should swap to the InitializationFragment view swapToFragmentView(ScreenList.INITIALIZATION_DIALOG); } else { levelSafeInvalidateOptionsMenu(); } }