List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.hpush.app.fragments.AboutDialogFragment.java
/** * Dialog to open showing the "End User License Agreement". * * @author Xinyue Zhao// w w w. j a va 2s .c om */ public static void showEula(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_eula"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new EulaDialog().show(ft, "dialog_eula"); }
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 .j a va2 s . c o m*/ } ft.addToBackStack(null); // Create and show the dialog. AboutDialog newFragment = AboutDialog.newInstance(1); newFragment.show(ft, "dialog"); }
From source file:com.agna.ferro.core.PersistentScreenScope.java
/** * @return PersistentScreenScope for corresponding screen or null, if it not exist *//*from w ww .j a va 2 s . c o m*/ @Nullable public static PersistentScreenScope find(FragmentManager fragmentManager, String screenName) { return (PersistentScreenScope) fragmentManager.findFragmentByTag(getName(screenName)); }
From source file:com.itsherpa.andg.imageloader.ContactImageCache.java
/** * Locate an existing instance of this Fragment or if not found, create and * add it using FragmentManager.// w w w . java 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 RetainFragmentContact findOrCreateRetainFragment(FragmentManager fm) { // Check to see if we have retained the worker fragment. RetainFragmentContact mRetainFragment = (RetainFragmentContact) fm.findFragmentByTag(TAG); // If not retained (or first time running), we need to create and add // it. if (mRetainFragment == null) { mRetainFragment = new RetainFragmentContact(); fm.beginTransaction().add(mRetainFragment, TAG).commitAllowingStateLoss(); } return mRetainFragment; }
From source file:com.grarak.kerneladiutor.utils.ViewUtils.java
public static void dismissDialog(FragmentManager manager) { FragmentTransaction ft = manager.beginTransaction(); Fragment fragment = manager.findFragmentByTag("dialog"); if (fragment != null) { ft.remove(fragment).commit();//from w w w. ja va2 s . c o m } }
From source file:com.example.signintest.SignInFragment.java
/** * Attach a SignInFragment to manage authentication in your activity. * // ww w. jav a2 s . c o m * @param activity The activity to attach the fragment to * @return */ public static SignInFragment getSignInFragment(FragmentActivity activity) { // Check if the fragment is already attached. FragmentManager fragmentManager = activity.getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(TAG_SIGNIN_FRAGMENT); if (fragment instanceof SignInFragment) { return (SignInFragment) fragment; } SignInFragment signInFragment = new SignInFragment(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(signInFragment, TAG_SIGNIN_FRAGMENT); fragmentTransaction.commit(); return signInFragment; }
From source file:com.google.android.apps.santatracker.games.PlayGamesFragment.java
/** * Get or create an instance of the Fragment attached to an Activity. * @param activity FragmentActivity to host the Fragment. * @param listener SignInListener to respond to changes in sign-in state. * @return instance of PlayGamesFragment. *//*w ww. j a v a2s .c o m*/ public static PlayGamesFragment getInstance(FragmentActivity activity, SignInListener listener) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); PlayGamesFragment result = null; Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG); if (fragment == null) { result = new PlayGamesFragment(); ft.add(result, FRAGMENT_TAG).disallowAddToBackStack().commit(); } else { result = (PlayGamesFragment) fragment; } result.setListener(listener); return result; }
From source file:com.example.levelup.core.app.ProgressFragment.java
/** * Dismisses any progress dialogs that are currently showing which match the given tag. * //from ww w. j av a 2s. c om * @param fragmentManager the fragment manager that possibly showed a progress fragment. * @param tag the tag on the fragment. */ public static void dismissAnyShowing(FragmentManager fragmentManager, String tag) { /* * Hide any progress dialog that may be showing. This is only done when no loader was found, * as the loader itself should dismiss the dialog otherwise. */ ProgressFragment progressFragment = (ProgressFragment) fragmentManager.findFragmentByTag(tag); if (progressFragment != null && progressFragment.isAdded()) { progressFragment.dismissAllowingStateLoss(); } }
From source file:com.malubu.wordpress.ratemedialogv4.RateMeDialogV4.java
/** * Called by each Button to hide this dialog. * @param ownerManager FragmentManager of the owner, the entity from which we showed a dialog. *///from w w w . j av a2s . c o m public static void hideRateMeDialog(FragmentManager ownerManager) { _lastOwnerManager = ownerManager; FragmentTransaction transaction = ownerManager.beginTransaction(); Fragment prev = ownerManager.findFragmentByTag(RATEMEDIALOG_TAG); if (prev != null) { transaction.remove(prev); } //Don't add this transaction to the back button. //transaction.addToBackStack(null); transaction.commit(); }
From source file:com.app.chasebank.contactslist.util.ImageCache.java
/** * Locate an existing instance of this Fragment or if not found, create and * add it using FragmentManager./*from w w w . j ava2s .c o 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 = (com.app.chasebank.contactslist.util.ImageCache.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).commitAllowingStateLoss(); } return mRetainFragment; }