List of usage examples for android.app FragmentTransaction addToBackStack
public abstract FragmentTransaction addToBackStack(@Nullable String name);
From source file:Main.java
public static void replaceFragment(FragmentManager manager, int parent, Fragment fragment) { FragmentTransaction ft = manager.beginTransaction(); ft.replace(parent, fragment);//from w ww . j a v a 2 s. c om ft.addToBackStack(null); ft.commit(); }
From source file:com.afollestad.overhear.ui.OverviewScreen.java
@SuppressLint("CommitTransaction") private static void showAboutDialog(Activity activity) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_about"); if (prev != null) ft.remove(prev);/* w w w.j a v a 2 s . c o m*/ ft.addToBackStack(null); new AboutDialog().show(ft, "dialog_about"); }
From source file:com.achep.activedisplay.DialogHelper.java
private static void showDialog(Activity activity, Class clazz, String tag) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(tag); if (prev != null) { ft.remove(prev);/*from w ww. ja v a 2 s . co m*/ } ft.addToBackStack(null); try { ((DialogFragment) clazz.newInstance()).show(ft, tag); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.poloure.simplerss.Utilities.java
private static void switchToFragment(Fragment fragment, boolean addToBackStack) { if (fragment.isHidden()) { Fragment[] fragments = { s_fragmentFavourites, s_fragmentManage, s_fragmentFeeds, s_fragmentSettings }; FragmentTransaction transaction = s_fragmentManager.beginTransaction(); for (Fragment frag : fragments) { if (frag.isVisible()) { transaction.hide(frag);//from w w w. j av a 2 s. co m } } transaction.show(fragment); if (addToBackStack) { transaction.addToBackStack(null); // Set the default transition for adding to the stack. transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } transaction.commit(); s_fragmentManager.executePendingTransactions(); fragment.getActivity().invalidateOptionsMenu(); } }
From source file:com.readystatesoftware.ghostlog.GhostLogSettingsFragment.java
private static void setupOpenSourceInfoPreference(final Activity activity, Preference preference) { preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/*from w w w . j a v a 2 s . c o m*/ public boolean onPreferenceClick(Preference preference) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new OpenSourceLicensesDialog().show(ft, "dialog"); return true; } }); }
From source file:com.readystatesoftware.ghostlog.GhostLogSettingsFragment.java
private static void setupVersionPref(final Activity activity, Preference preference) { preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override//from ww w . j a v a2 s . c om public boolean onPreferenceClick(Preference preference) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new AboutDialog().show(ft, "dialog"); return true; } }); }
From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java
/** * ??Fragment.//www. java2 s. c o m * * @param context * the context */ public static void removeDialog(Context context) { try { FragmentActivity activity = (FragmentActivity) context; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); ft.commit(); } catch (Exception e) { // ?Activity?? e.printStackTrace(); } }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void showMenuFragment(Activity app) { if (app == null) { Log.e(TAG, "showReceiveFragment: app is null"); return;/*from w w w . j a v a 2s. c o m*/ } FragmentTransaction transaction = app.getFragmentManager().beginTransaction(); transaction.setCustomAnimations(0, 0, 0, R.animator.plain_300); transaction.add(android.R.id.content, new FragmentMenu(), FragmentMenu.class.getName()); transaction.addToBackStack(FragmentMenu.class.getName()); transaction.commit(); }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void showGreetingsMessage(Activity app) { if (app == null) { Log.e(TAG, "showGreetingsMessage: app is null"); return;/*from w w w . j a va2 s. c om*/ } FragmentTransaction transaction = app.getFragmentManager().beginTransaction(); transaction.setCustomAnimations(0, 0, 0, R.animator.plain_300); transaction.add(android.R.id.content, new FragmentGreetings(), FragmentGreetings.class.getName()); transaction.addToBackStack(FragmentGreetings.class.getName()); transaction.commit(); }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void showBreadSignal(Activity activity, String title, String iconDescription, int drawableId, BROnSignalCompletion completion) { fragmentSignal = new FragmentSignal(); Bundle bundle = new Bundle(); bundle.putString(FragmentSignal.TITLE, title); bundle.putString(FragmentSignal.ICON_DESCRIPTION, iconDescription); fragmentSignal.setCompletion(completion); bundle.putInt(FragmentSignal.RES_ID, drawableId); fragmentSignal.setArguments(bundle); FragmentTransaction transaction = activity.getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_bottom, R.animator.from_bottom, R.animator.to_bottom);//from ww w.jav a 2s . c om transaction.add(android.R.id.content, fragmentSignal, fragmentSignal.getClass().getName()); transaction.addToBackStack(null); if (!activity.isDestroyed()) transaction.commit(); }