List of usage examples for android.support.v4.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.deange.textfaker.ui.dialog.EditMessageDialog.java
public static void show(EditMessageDialog dialog, final Callback callback, final FragmentManager manager, final ConversationMessage message) { Log.v(TAG, "show()"); final FragmentTransaction transaction = manager.beginTransaction(); if (dialog != null) { transaction.remove(dialog);/*from ww w . j a v a 2s.c o m*/ } dialog = new EditMessageDialog(message, callback); dialog.show(transaction, EditMessageDialog.TAG); }
From source file:com.darshancomputing.BatteryIndicatorPro.PersistentFragment.java
public static PersistentFragment getInstance(FragmentManager fm) { PersistentFragment pfrag = (PersistentFragment) fm.findFragmentByTag(FRAG_TAG); if (pfrag == null) { pfrag = new PersistentFragment(); fm.beginTransaction().add(pfrag, FRAG_TAG).commit(); }/* ww w .jav a 2 s. c o m*/ return pfrag; }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
/** * The {@code fragment} is added to the container view with msgId {@code frameId}. The operation is * performed by the {@code fragmentManager}. */// w w w. j a v a2s .com public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { // checkNotNull(fragmentManager); // checkNotNull(fragment); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.addToBackStack(fragment.getClass().getSimpleName()); transaction.commit(); }
From source file:com.battlelancer.seriesguide.ui.dialogs.AddDialogFragment.java
/** * Display a dialog which asks if the user wants to add the given show to his show database. If * necessary an AsyncTask will be started which takes care of adding the show. */// ww w .j av a 2s . com public static void showAddDialog(SearchResult show, FragmentManager fm) { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = AddDialogFragment.newInstance(show); newFragment.show(ft, "dialog"); }
From source file:com.battlelancer.seriesguide.ui.dialogs.AddListDialogFragment.java
/** * Display a dialog which allows to edit the title of this list or remove * it.//from w w w . jav a 2 s. c o m */ public static void showAddListDialog(FragmentManager fm) { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("addlistdialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = AddListDialogFragment.newInstance(); newFragment.show(ft, "addlistdialog"); }
From source file:au.com.museumvictoria.fieldguide.bunurong.util.RetainFragment.java
/** * Locate an existing instance of this Fragment or if not found, create and * add it using FragmentManager.//from ww w . ja va2 s .c om * * @param fm The FragmentManager manager to use. * @return The existing instance of the Fragment or the new instance if just * created. */ public static RetainFragment findOrCreateRetainFragment(FragmentManager fm) { // Check to see if we have retained the worker fragment. RetainFragment mRetainFragment = (RetainFragment) fm.findFragmentByTag(TAG); // If not retained (or first time running), we need to create and add it. if (mRetainFragment == null) { mRetainFragment = new RetainFragment(); fm.beginTransaction().add(mRetainFragment, TAG).commit(); } return mRetainFragment; }
From source file:Main.java
public static void replaceFragment(FragmentManager fragmentManager, int frameId, Fragment fragmentToShow, String fragmentTag, Stack<Fragment> fragmentStack) { if (fragmentToShow == null) { return;/* w w w .ja v a2 s.c o m*/ } List<Fragment> fragmentList = fragmentManager.getFragments(); for (Fragment fragment : fragmentList) { if (fragment == null) { continue; } fragmentManager.beginTransaction().remove(fragment).commit(); if (!fragmentStack.empty()) { fragmentStack.pop(); } } fragmentManager.beginTransaction().add(frameId, fragmentToShow, fragmentTag).commit(); fragmentStack.push(fragmentToShow); }
From source file:com.baseproject.image.RetainFragment.java
/** * Locate an existing instance of this Fragment or if not found, create and * add it using FragmentManager./*from w w w.j a va 2s. co m*/ * * @param fm * The FragmentManager manager to use. * @return The existing instance of the Fragment or the new instance if just * created. */ public static RetainFragment findOrCreateRetainFragment(FragmentManager fm) { // Check to see if we have retained the worker fragment. RetainFragment mRetainFragment = (RetainFragment) fm.findFragmentByTag(TAG); // If not retained (or first time running), we need to create and add // it. if (mRetainFragment == null) { mRetainFragment = new RetainFragment(); fm.beginTransaction().add(mRetainFragment, TAG).commit(); } return mRetainFragment; }
From source file:ca.rmen.android.poetassistant.main.dictionaries.ConfirmDialogFragment.java
public static void show(int actionId, String message, String positiveAction, FragmentManager fragmentManager, String tag) {/*from www . java 2 s . co m*/ ConfirmDialogFragment fragment = new ConfirmDialogFragment(); Bundle bundle = new Bundle(3); bundle.putInt(EXTRA_ACTION_ID, actionId); bundle.putString(EXTRA_MESSAGE, message); bundle.putString(EXTRA_POSITIVE_ACTION, positiveAction); fragment.setArguments(bundle); fragmentManager.beginTransaction().add(fragment, tag).commit(); }
From source file:com.dm.material.dashboard.candybar.fragments.dialog.InAppBillingFragment.java
public static void showInAppBillingDialog(@NonNull FragmentManager fm, BillingProcessor billingProcessor, int type, @NonNull String key, @NonNull String[] productId, int[] productCount) { mBillingProcessor = billingProcessor; FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev);/* w ww . j a v a 2 s. c o m*/ } try { DialogFragment dialog = InAppBillingFragment.newInstance(type, key, productId, productCount); dialog.show(ft, TAG); } catch (IllegalArgumentException | IllegalStateException ignored) { } }