List of usage examples for android.app FragmentTransaction addToBackStack
public abstract FragmentTransaction addToBackStack(@Nullable String name);
From source file:com.ternup.caddisfly.fragment.DetailsFragment.java
private void goBack() { FragmentManager fm = getFragmentManager(); try {/*from w w w . j av a2 s .co m*/ if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); fm.executePendingTransactions(); } else { Fragment fragment = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.replace(R.id.container, fragment, "0"); ft.addToBackStack(null); ft.commit(); fm.executePendingTransactions(); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(0, true); drawerList.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.example.corppool.controller.MainActivity.java
private void showAddNewFeed() { Fragment fragment = new AddNewFeed(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("newfeed"); // this will manage backstack transaction.commit();/*www .ja va 2s . c o m*/ }
From source file:com.example.corppool.controller.MainActivity.java
private void showFeedresults() { Fragment fragment = new Feeds_results(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("feedresults"); // this will manage backstack transaction.commit();/*from w w w . jav a2 s . c o m*/ }
From source file:com.example.corppool.controller.MainActivity.java
private void showMyFeeds() { Fragment fragment = new MyFeeds(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("feedresultsTemp"); // this will manage backstack transaction.commit();// w ww.j av a 2 s .co m }
From source file:com.example.android.AudioArchive.ui.MusicPlayerActivity.java
private void navigateToBrowser(String mediaId) { LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId); MediaBrowserFragment fragment = getBrowseFragment(); if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) { fragment = new MediaBrowserFragment(); fragment.setMediaId(mediaId);//w w w . jav a2 s . co m FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.slide_in_from_right, R.animator.slide_out_to_left, R.animator.slide_in_from_left, R.animator.slide_out_to_right); transaction.replace(R.id.container, fragment, FRAGMENT_TAG); // If this is not the top level media (root), we add it to the fragment back stack, // so that actionbar toggle and Back will work appropriately: if (mediaId != null) { transaction.addToBackStack(null); } transaction.commit(); } }
From source file:com.example.corppool.controller.MainActivity.java
public void showConfirmPage(Feed feed) { Fragment fragment = ConfirmFeedSubmit.newInstance(feed); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack(null); // this will manage backstack transaction.commit();//from w ww . j a v a2 s . co m }
From source file:blackman.matt.infinitebrowser.InfinityBrowser.java
/** * Creates a new board for a post when reply button is hit. * * @param boardRoot Link to the thread to open up * @param threadNo Thread no being opened *//*from w w w .j a va2 s .c om*/ @Override public void onReplyClicked(String boardRoot, String threadNo) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); Boolean ageAccept = preferences.getBoolean("age_guard_accept", false); if (ageAccept) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); LinearLayout helpText = (LinearLayout) findViewById(R.id.ll_help_add_boards); Board newThread = Board.newInstance(boardRoot, threadNo); fragmentTransaction.replace(R.id.container, newThread, threadNo); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); helpText.setVisibility(View.GONE); mTitle = boardRoot.replace("https://8chan.co", "") + threadNo; setTitle(mTitle); } }
From source file:io.coldstart.android.TrapListActivity.java
public void ShowRegisterDialog() { if (dialogFragment != null) dialogFragment.dismiss();/*w w w. j a v a 2 s . c om*/ FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); Log.i("prev", "Removing"); } ft.addToBackStack(null); // Create and show the dialog. dialogFragment = StartupRegisterDialog.newInstance(GCMRegistrar.getRegistrationId(this)); dialogFragment.setCancelable(true); dialogFragment.show(ft, "dialog"); }
From source file:io.coldstart.android.TrapListActivity.java
public void ShowLoginDialog() { if (dialogFragment != null) dialogFragment.dismiss();/* www . j a va2 s.co m*/ FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); Log.i("prev", "Removing"); } ft.addToBackStack(null); // Create and show the dialog. dialogFragment = StartupLoginDialog.newInstance(GCMRegistrar.getRegistrationId(this)); dialogFragment.setCancelable(true); dialogFragment.show(ft, "dialog"); }
From source file:blackman.matt.infinitebrowser.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. *//* w w w. j av a 2 s .c om*/ public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { /** * Handles the drawer being closed. * * @param drawerView The drawer being closed. */ @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } /** * Handles the drawer being opened. * * @param drawerView The drawer being opened. */ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } setUpListAdapter(); getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String boardRoot = "/tech/"; if (view instanceof TextView) { boardRoot = ((TextView) view).getText().toString(); } FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Board newBoard = Board.newInstance(boardRoot); fragmentTransaction.replace(R.id.container, newBoard, boardRoot); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); closeDrawer(); } }); // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }