List of usage examples for android.app FragmentTransaction addToBackStack
public abstract FragmentTransaction addToBackStack(@Nullable String name);
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;/*from www . j a v a 2 s .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:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showAbout() { popBackStackFull();/*from ww w .j av a 2 s. c o m*/ FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, new RMBTAboutFragment(), AppConstants.PAGE_TITLE_ABOUT); ft.addToBackStack(AppConstants.PAGE_TITLE_ABOUT); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_ABOUT); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showResultsAfterTest(String testUuid) { popBackStackFull();/*from w w w. j a v a 2s.c o m*/ final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment(); final Bundle args = new Bundle(); args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid); fragment.setArguments(args); final FragmentManager fm = getFragmentManager(); final FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * //from ww w .j ava2 s . co m * @param itemList * @param pos */ public void showHistoryPager(final int pos) { if (historyStorageList != null) { // final RMBTHistoryPagerFragment fragment = new RMBTHistoryPagerFragment(); final Bundle args = new Bundle(); final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment(); String testUuid = historyStorageList.get(pos).get("test_uuid"); //testUuid = "842356d7-a863-48f9-8220-678125fb3a76"; //testUuid = "0d765559-ab16-4fa1-b776-4040e18bf134"; //testUuid = "dbf47f08-711f-4cfa-9fd9-78f06a7a7df3"; args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid); fragment.setArguments(args); final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER); } }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * // ww w . j ava 2 s. co m * @param popStack */ public void showHistory(final boolean popStack) { popBackStackFull(); FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, new RMBTHistoryFragment(), AppConstants.PAGE_TITLE_HISTORY); ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); if (popStack) { fm.popBackStack(); } ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_HISTORY); }
From source file:com.hijacker.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.reset: stop(PROCESS_AIRODUMP);/*from w w w. ja v a 2 s . c om*/ Tile.clear(); Tile.onCountsChanged(); Airodump.startClean(); return true; case R.id.stop_run: if (Airodump.isRunning()) stop(PROCESS_AIRODUMP); else Airodump.start(); return true; case R.id.stop_aireplay: stop(PROCESS_AIREPLAY); return true; case R.id.filter: new FiltersDialog().show(mFragmentManager, "FiltersDialog"); return true; case R.id.settings: if (currentFragment != FRAGMENT_SETTINGS) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.replace(R.id.fragment1, new SettingsFragment()); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commitAllowingStateLoss(); } return true; case R.id.export: new ExportDialog().show(mFragmentManager, "ExportDialog"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showNdtCheck() { final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.NDT), AppConstants.PAGE_TITLE_NDT_CHECK); ft.addToBackStack(AppConstants.PAGE_TITLE_NDT_CHECK); ft.commit();/*from w w w . j a v a2 s .c o m*/ }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showLogFragment() { FragmentTransaction ft; ft = fm.beginTransaction();// w w w. j a v a 2 s .c o m final Fragment fragment = new LogFragment(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_LOG); ft.addToBackStack(AppConstants.PAGE_TITLE_LOG); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_LOG); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * /*from ww w. j a va2 s .c o m*/ */ public void showSync() { FragmentTransaction ft; ft = fm.beginTransaction(); final Fragment fragment = new RMBTSyncFragment(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_SYNC); ft.addToBackStack(AppConstants.PAGE_TITLE_SYNC); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_SYNC); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showNetstatFragment() { FragmentTransaction ft; ft = fm.beginTransaction();/*from www . ja v a 2 s .com*/ final Fragment fragment = new NetstatFragment(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_NETSTAT); ft.addToBackStack(AppConstants.PAGE_TITLE_NETSTAT); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_NETSTAT); }