List of usage examples for android.support.v4.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.dm.material.dashboard.candybar.fragments.dialog.IntentChooserFragment.java
public static void showIntentChooserDialog(@NonNull FragmentManager fm, @NonNull Request request) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev);//from w w w. ja va2 s . c o m } try { DialogFragment dialog = IntentChooserFragment.newInstance(request); dialog.show(ft, TAG); } catch (IllegalArgumentException | IllegalStateException ignored) { } }
From source file:Main.java
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { // checkNotNull(fragmentManager); // checkNotNull(fragment); if (fragmentManager != null && fragment != null) { FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.commit();/*ww w . j av a 2 s . c om*/ } }
From source file:com.bdevlin.apps.utils.HelpUtils.java
public static void showOpenSourceLicenses(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_licenses"); if (prev != null) { ft.remove(prev);/*from w ww .j a v a 2s. com*/ } ft.addToBackStack(null); new OpenSourceLicensesDialog().show(ft, "dialog_licenses"); }
From source file:ca.six.unittestapp.todo.util.ActivityUtils.java
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. * *///w w w .j av a 2 s .com public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { checkNotNull(fragmentManager); //reason to use checkNotNull since calling this method may throw NullPointerException. checkNotNull(fragment); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.commit(); }
From source file:com.bdevlin.apps.utils.HelpUtils.java
public static void showDialog(HelpActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev);//from w w w . jav a2 s . com } ft.addToBackStack(null); // Create and show the dialog. AboutDialog newFragment = AboutDialog.newInstance(1); newFragment.show(ft, "dialog"); }
From source file:Main.java
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. * *//*from w w w .ja va 2 s . co m*/ public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull List<Fragment> fragmentArray, List<Integer> frameIdArray) { checkNotNull(fragmentManager); for (Fragment item : fragmentArray) { checkNotNull(item); } FragmentTransaction transaction = fragmentManager.beginTransaction(); for (int i = 0; i < fragmentArray.size(); i++) { transaction.replace(frameIdArray.get(i), fragmentArray.get(i)); } transaction.commit(); }
From source file:com.by_syk.lib.nanoiconpack.fragment.RetainedFragment.java
@NonNull public static RetainedFragment initRetainedFragment(@NonNull FragmentManager fragmentManager, @NonNull String tag) {/*from w w w .j a v a 2s. c om*/ RetainedFragment fragment = (RetainedFragment) fragmentManager.findFragmentByTag(tag); if (fragment == null) { fragment = new RetainedFragment(); fragmentManager.beginTransaction().add(fragment, tag).commit(); } return fragment; }
From source file:Main.java
/** * This method clears backstack and loads fragment in a root. * //from www . jav a 2s. c om * @param fragmentActivity * @param fragmentContainerId * @param fragmentClass * @param bundle * @param tag * @return true if loaded successfully, false otherwise */ public static boolean loadFragmentInRoot(FragmentActivity fragmentActivity, int fragmentContainerId, Class<? extends Fragment> fragmentClass, Bundle bundle, String tag) { // TODO Auto-generated method stub boolean status = false; FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); // remove all fragments from back stack fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); // add new fragment FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out, android.R.anim.fade_in, android.R.anim.fade_out); Fragment fragment; try { fragment = fragmentClass.newInstance(); fragment.setArguments(bundle); fragmentTransaction.replace(fragmentContainerId, fragment, tag).commit(); // finish pending transactions fragmentManager.executePendingTransactions(); status = true; } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } return status; }
From source file:com.deange.textfaker.ui.dialog.ConfirmDeleteDialog.java
public static void show(ConfirmDeleteDialog dialog, final Callback callback, final FragmentManager manager, final Class<?> clazz, final long itemId, final String message) { Log.v(TAG, "show()"); final FragmentTransaction transaction = manager.beginTransaction(); if (dialog != null) { transaction.remove(dialog);/*from ww w. j a va2s. c om*/ } dialog = ConfirmDeleteDialog.createInstance(clazz, itemId, message); dialog.setCallback(callback); dialog.show(transaction, ConfirmDeleteDialog.TAG); }
From source file:cn.nekocode.rxlifecycle.compact.RxLifecycleCompact.java
public static RxLifecycleCompact bind(@NonNull FragmentManager fragmentManager) { BindingV4Fragment fragment = (BindingV4Fragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (fragment == null) { fragment = new BindingV4Fragment(); final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(fragment, FRAGMENT_TAG); transaction.commit();/*from w w w . j a v a 2 s .c o m*/ } else if (fragment.isDetached()) { final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.attach(fragment); transaction.commit(); } return bind(fragment.getLifecycleBehavior()); }