List of usage examples for android.app FragmentTransaction addToBackStack
public abstract FragmentTransaction addToBackStack(@Nullable String name);
From source file:org.catnut.ui.PluginsActivity.java
public void flipCard(Fragment fragment, String tag, boolean backStack) { FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction//from www.j av a2 s .c o m .setCustomAnimations(R.animator.card_flip_right_in, R.animator.card_flip_right_out, R.animator.card_flip_left_in, R.animator.card_flip_left_out) .replace(android.R.id.content, fragment, tag); if (backStack) { fragmentTransaction.addToBackStack(null); } fragmentTransaction.commit(); mHandler.post(new Runnable() { @Override public void run() { invalidateOptionsMenu(); } }); }
From source file:it.gmariotti.cardslib.demo.MainNativeActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fragment_main, baseFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();// w w w .ja va2 s . co m if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); } }
From source file:com.aokp.romcontrol.github.tasks.DisplayProjectsListTask.java
private void loadProjectsToArray(JSONArray repoProjectsArray) { // scroll through each item in array (projects in repo organization) for (int i = 0; i < repoProjectsArray.length(); i++) { try {/*from ww w . j a va 2 s. co m*/ final JSONObject projectsObject = (JSONObject) repoProjectsArray.get(i); final Preference mProject = mCategory.getPreferenceManager().createPreferenceScreen(mContext); // extract info about each project final String projectName = projectsObject.getString("name"); String projectDescription = projectsObject.getString("description"); int githubProjectId = projectsObject.getInt("id"); // apply info to our preference screen mProject.setKey(projectName); if (projectDescription.contains("") || projectDescription == null) { mProject.setTitle(projectName); mProject.setSummary(projectDescription); } else { mProject.setTitle(projectDescription); mProject.setSummary(projectName); } mProject.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference p) { AlertDialog.Builder adb = new AlertDialog.Builder(mAlertDialog.getContext()); if (!mFavPackagesStorage.isFavProject(projectName)) { adb.setNegativeButton(R.string.changelog_add_to_favs_list, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.d(TAG, "fav packages size==" + mFavPackagesStorage.getFavProjects().size()); if (mFavPackagesStorage.getFavProjects().size() > 0) { mPreferenceScreen.addPreference(mFavProjects); } mFavPackagesStorage.addProject(projectName); mCategory.removePreference(mProject); mFavProjects.addPreference(mProject); } }).setMessage(R.string.add_favs_or_view); } else { adb.setNegativeButton(R.string.changelog_remove_from_favs_list, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mFavPackagesStorage.removeProject(projectName); mFavProjects.removePreference(mProject); mCategory.addPreference(mProject); Log.d(TAG, "fav packages size==" + mFavPackagesStorage.getFavProjects().size()); if (mFavPackagesStorage.getFavProjects().size() == 1) { mPreferenceScreen.removePreference(mFavProjects); } } }).setMessage(R.string.remove_favs_or_view); } adb.setPositiveButton(R.string.changelog_view_commits, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { FragmentTransaction transaction = mFragmentManager.beginTransaction(); CommitsFragment commitFragment = new CommitsFragment(mAlertDialog, projectName); transaction.addToBackStack(null); transaction.replace(mId, commitFragment, projectName); transaction.commit(); } }).create().show(); return true; } }); if (mFavPackagesStorage.isFavProject(projectName)) { if (mFavProjects.findPreference(projectName) == null) { Log.d(TAG, "found Favorite Project: " + projectName); mFavProjects.addPreference(mProject); } } else { if (DEBUG) Log.d(TAG, "adding normal project: " + projectName); mCategory.addPreference(mProject); } } catch (JSONException badJsonRequest) { Log.e(TAG, "failed to parse required info about project", badJsonRequest); } } if (mFavPackagesStorage.getFavProjects().size() > 0) mPreferenceScreen.addPreference(mFavProjects); }
From source file:es.rgmf.libresportgps.MainActivity.java
/** * This method is called when user click on track list item in the * TrackListFragment fragment./*from w ww . ja va 2s.c om*/ * * @param track * The track selected. */ @Override public void onTrackSelected(Track track) { TrackDetailFragment tdf = TrackDetailFragment.newInstance(); tdf.setTrack(track); FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.replace(R.id.container, tdf); transaction.addToBackStack(null); // Add this fragment to stack because // the user can // back to the latter fragment. transaction.commitAllowingStateLoss(); }
From source file:de.sourcestream.movieDB.controller.GenresList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *//* w w w . ja v a2s . c o m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (movieList.getCurrentList().equals("genre/" + genresList.get(position).getId() + "/movies")) movieList.setBackState(1); else { movieList.setCurrentList("genre/" + genresList.get(position).getId() + "/movies"); movieList.setBackState(0); } movieList.setTitle(genresList.get(position).getName()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle args = new Bundle(); args.putString("currentList", "genresList"); movieList.setArguments(args); transaction.replace(R.id.frame_container, movieList); // add the current transaction to the back stack: transaction.addToBackStack("genresList"); transaction.commit(); backState = 1; }
From source file:la.marsave.fullscreentest.MainActivity.java
/** * This method is used to toggle between the two fragment states by * calling the appropriate animations between them. The entry and exit * animations of the text fragment are specified in R.animator resource * files. The entry and exit animations of the image fragment are * specified in the slideBack and slideForward methods below. The reason * for separating the animation logic in this way is because the translucent * dark hover view must fade in at the same time as the image fragment * animates into the background, which would be difficult to time * properly given that the setCustomAnimations method can only modify the * two fragments in the transaction./*ww w . j a v a2 s. c o m*/ */ private void switchFragments() { if (mIsAnimating) { return; } mIsAnimating = true; if (mDidSlideOut) { mDidSlideOut = false; getFragmentManager().popBackStack(); } else { mDidSlideOut = true; Animator.AnimatorListener listener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator arg0) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.slide_fragment_in, 0, 0, R.animator.slide_fragment_out); transaction.add(R.id.move_to_back_container, mTextFragment); transaction.addToBackStack(null); transaction.commit(); } }; slideBack(listener); } }
From source file:com.ffmpeger.card.MainNativeActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(com.ffmpeger.card.R.id.fragment_main, baseFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();// w w w . j a va 2 s. c om if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); } }
From source file:produvia.com.lights.SmartLightsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mErrorOccurred = false;// w w w . jav a 2s .co m mErrorMessage = ""; setContentView(R.layout.activity_smart_lights); listFragment = new SmartLightsFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment, listFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); //Start running the discovery service in the background //any discovered services will be reported on the onTaskUpdate callback: if (RUN_DISCOVERY) { WeaverSdkApi.discoveryService(this, true); } //fetch the services that have already been discovered in previous scans //these services will be returned in the onTaskCompleted callback: WeaverSdkApi.servicesGet(this, null); }
From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java
private void showDialogFragment(final FragmentManager fragmentManager, final DialogFragment dialogFragment, final boolean addToBackStack, final String tag) { final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(dialogFragment, tag); if (addToBackStack) { transaction.addToBackStack(tag); }/* w w w.j a v a 2 s. com*/ transaction.commitAllowingStateLoss(); }
From source file:com.android.mail.ui.TwoPaneController.java
@Override public void launchFragment(final Fragment fragment, final int selectPosition) { final int containerViewId = TwoPaneLayout.MISCELLANEOUS_VIEW_ID; final FragmentManager fragmentManager = mActivity.getFragmentManager(); if (fragmentManager.findFragmentByTag(TAG_CUSTOM_FRAGMENT) == null) { final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.addToBackStack(null); fragmentTransaction.replace(containerViewId, fragment, TAG_CUSTOM_FRAGMENT); mMiscellaneousViewTransactionId = fragmentTransaction.commitAllowingStateLoss(); fragmentManager.executePendingTransactions(); }/*from ww w . ja v a2 s .c o m*/ if (selectPosition >= 0) { getConversationListFragment().setRawSelected(selectPosition, true); } }