List of usage examples for android.support.v4.app FragmentTransaction commitAllowingStateLoss
public abstract int commitAllowingStateLoss();
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 v a2s . co m public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId, String tag) { FragmentTransaction transaction = fragmentManager.beginTransaction(); // transaction.add(frameId, fragment); transaction.replace(frameId, fragment, tag); // transaction.commit(); transaction.commitAllowingStateLoss(); }
From source file:cc.mintcoin.wallet.ui.HelpDialogFragment.java
public static void page(final FragmentManager fm, @Nonnull final int messageResId) { final DialogFragment newFragment = HelpDialogFragment.instance(messageResId); FragmentTransaction ft = fm.beginTransaction(); ft.add(newFragment, FRAGMENT_TAG);/*ww w . j a v a2 s.c o m*/ try { ft.commit(); } catch (IllegalStateException ise) { ft.commitAllowingStateLoss(); } }
From source file:com.dmitrymalkovich.android.githubanalytics.Utils.java
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. *///from w ww .ja v a 2 s. c o m public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.commitAllowingStateLoss(); }
From source file:com.dmitrymalkovich.android.githubanalytics.Utils.java
public static void replaceFragment(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(frameId, fragment); transaction.commitAllowingStateLoss(); }
From source file:org.runbuddy.tomahawk.utils.FragmentUtils.java
/** * Add the given {@link Fragment} to the container with the given id. * * @param activity {@link TomahawkMainActivity} needed as a context object * @param clss Class of the {@link Fragment} to instantiate * @param bundle {@link Bundle} which contains arguments (can be null) * @param containerResId the resource id of the {@link android.view.ViewGroup} to which the * Fragment will be added *///from w ww . java2 s.c o m public static void add(TomahawkMainActivity activity, Class clss, Bundle bundle, int containerResId) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.add(containerResId, Fragment.instantiate(activity, clss.getName(), bundle), FRAGMENT_TAG); ft.addToBackStack(clss.getName()); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commitAllowingStateLoss(); Log.d(TAG, "Added fragment " + clss.getSimpleName() + ", Bundle: " + bundle); }
From source file:com.yallaya.fragments.FragmentsModule.java
public static void s_add(Object arg) { HashMap<String, Object> options = (HashMap) arg; if (!options.containsKey("fragment") || !options.containsKey("frameId")) { return;/* w w w . j a va 2s. c o m*/ } FragmentProxy proxy = (FragmentProxy) options.get("fragment"); int frameId = TiConvert.toInt(options.get("frameId")); TiFragment frg = proxy.fragment; if (frg.isAdded()) { return; } FragmentTransaction ft = getTransaction(options); ft.add(frameId, frg, proxy.getTag()); ft.commitAllowingStateLoss(); }
From source file:org.runbuddy.tomahawk.utils.FragmentUtils.java
/** * Replaces the current {@link Fragment} in the container with the given id. Allows to specify * the {@link String} with which to tag the replaced {@link Fragment}. * * @param activity {@link TomahawkMainActivity} needed as a context object * @param clss Class of the {@link Fragment} to instantiate * @param bundle {@link Bundle} which contains arguments (can be null) * @param containerResId the resource id of the {@link android.view.ViewGroup} in which the * Fragment will be replaced * @param tag a {@link String} id to tag the replaced {@link Fragment} with *//*from ww w. ja v a2 s . co m*/ public static void replace(TomahawkMainActivity activity, Class clss, Bundle bundle, int containerResId, String tag) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.replace(containerResId, Fragment.instantiate(activity, clss.getName(), bundle), tag); if (containerResId == R.id.content_viewer_frame) { ft.addToBackStack(clss.getName()); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commitAllowingStateLoss(); activity.collapsePanel(); Log.d(TAG, "Current fragment is now " + clss.getSimpleName() + ", Bundle: " + bundle); }
From source file:com.microsoft.rightsmanagement.sampleapp.App.java
/** * Display message dialog./* w ww . j a v a2 s.c o m*/ * * @param message the message */ public static void displayMessageDialog(FragmentManager supportedFragmentManager, String message) { FragmentTransaction fragmentTransaction = supportedFragmentManager.beginTransaction(); Fragment previous = supportedFragmentManager.findFragmentByTag(MessageDialogFragment.TAG); if (previous != null) { fragmentTransaction.remove(previous); } DialogFragment newFragment = MessageDialogFragment.newInstance(message); fragmentTransaction.add(newFragment, MessageDialogFragment.TAG); fragmentTransaction.commitAllowingStateLoss(); }
From source file:com.microsoft.rightsmanagement.sampleapp.App.java
/** * Display progress dialog./* ww w . j a va 2s. c o m*/ * * @param message the message */ public static void displayProgressDialog(FragmentManager supportedFragmentManager, String message) { FragmentTransaction fragmentTransaction = supportedFragmentManager.beginTransaction(); Fragment previous = supportedFragmentManager.findFragmentByTag(ProgressDialogFragment.TAG); if (previous != null) { fragmentTransaction.remove(previous); } DialogFragment newFragment = ProgressDialogFragment.newInstance(message); fragmentTransaction.add(newFragment, ProgressDialogFragment.TAG); fragmentTransaction.commitAllowingStateLoss(); sProgressDialogFragment = newFragment;// save }
From source file:com.kubotaku.android.code4kyoto5374.SegregationActivity.java
private void showSegregationView() { FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentByTag(SegregationFragment.TAG) == null) { SegregationFragment fragment = SegregationFragment.newInstance(); FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.view_holder, fragment, SegregationFragment.TAG); ft.commitAllowingStateLoss(); }/*from w w w. ja v a 2 s . c o m*/ }