List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.hangulo.powercontact.OpensourceFragment.java
/** * Builds and displays a licenses fragment with no Close button. Requires * "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be * present.//from w w w .j av a2 s . c o m * * @param fm A fragment manager instance used to display this LicensesFragment. */ public static void displayLicensesFragment(FragmentManager fm) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = OpensourceFragment.newInstance(); newFragment.show(ft, FRAGMENT_TAG); }
From source file:com.jaspersoft.android.jaspermobile.dialog.ProgressDialogFragment.java
public static ProgressDialogFragment getInstance(FragmentManager fm) { if (fm == null) return null; return (ProgressDialogFragment) fm.findFragmentByTag(TAG); }
From source file:cn.nekocode.rxactivityresult.compact.RxActivityResultCompact.java
private static Observable<ActivityResult> startActivityForResult(@NonNull FragmentManager fragmentManager, @NonNull final Intent intent, final int requestCode, @Nullable final Bundle options) { ResultHandleV4Fragment _fragment = (ResultHandleV4Fragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (_fragment == null) { _fragment = new ResultHandleV4Fragment(); final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(_fragment, FRAGMENT_TAG); transaction.commit();//from ww w .j a v a 2 s. co m } else if (_fragment.isDetached()) { final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.attach(_fragment); transaction.commit(); } final ResultHandleV4Fragment fragment = _fragment; return fragment.getIsAttachedBehavior().filter(new Predicate<Boolean>() { @Override public boolean test(@io.reactivex.annotations.NonNull Boolean isAttached) throws Exception { return isAttached; } }).flatMap(new Function<Boolean, ObservableSource<ActivityResult>>() { @Override public ObservableSource<ActivityResult> apply(@io.reactivex.annotations.NonNull Boolean aBoolean) throws Exception { fragment.startActivityForResult(intent, requestCode, options); return fragment.getResultPublisher(); } }).filter(new Predicate<ActivityResult>() { @Override public boolean test(@io.reactivex.annotations.NonNull ActivityResult result) throws Exception { return result.getRequestCode() == requestCode; } }); }
From source file:com.maxwen.wallpaper.board.fragments.dialogs.WallpaperApplyFragment.java
public static void showWallpaperApply(FragmentManager fm, final RectF rectF, final String url, final String name) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev);//from www. j ava 2 s. c o m } try { DialogFragment dialog = WallpaperApplyFragment.newInstance(rectF, url, name); dialog.show(ft, TAG); } catch (IllegalStateException | IllegalArgumentException ignored) { } }
From source file:com.jaspersoft.android.jaspermobile.qa.DriveSelectFileDialog.java
public static void handleActivityResult(FragmentManager fm, int requestCode, int resultCode, Intent data) { DriveSelectFileDialog dialog = (DriveSelectFileDialog) fm.findFragmentByTag(TAG); if (dialog != null) { dialog.onActivityResult(requestCode, resultCode, data); }// w w w . j a v a 2s .c o m }
From source file:com.google.android.apps.iosched.util.WiFiUtils.java
public static void showWiFiDialog(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_wifi"); if (prev != null) { ft.remove(prev);/*from w ww . j a v a 2s. c om*/ } ft.addToBackStack(null); new WiFiDialog(isWiFiEnabled(activity)).show(ft, "dialog_wifi"); }
From source file:com.google.android.apps.santatracker.invites.AppInvitesFragment.java
public static AppInvitesFragment getInstance(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); AppInvitesFragment result = null;//from w w w. j a va 2 s .c o m Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG); if (fragment == null) { result = new AppInvitesFragment(); ft.add(result, FRAGMENT_TAG).disallowAddToBackStack().commit(); } else { result = (AppInvitesFragment) fragment; } return result; }
From source file:com.hangulo.powercontact.OpensourceFragment.java
/** * Builds and displays a licenses fragment with or without a Close button. * Requires "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" * to be present./*from www. j a va 2 s. co m*/ * * @param fm A fragment manager instance used to display this LicensesFragment. * @param showCloseButton Whether to show a Close button at the bottom of the dialog. */ public static void displayLicensesFragment(FragmentManager fm, boolean showCloseButton) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = OpensourceFragment.newInstance(showCloseButton); newFragment.show(ft, FRAGMENT_TAG); }
From source file:com.conferenceengineer.android.iosched.util.WiFiUtils.java
public static void showWiFiDialog(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_wifi"); if (prev != null) { ft.remove(prev);//www.ja v a 2s. co m } ft.addToBackStack(null); Bundle arguments = new Bundle(); arguments.putBoolean(WiFiDialog.WIFI_ENABLED_KEY, isWiFiEnabled(activity)); WiFiDialog wifiDialog = new WiFiDialog(); wifiDialog.setArguments(arguments); wifiDialog.show(ft, "dialog_wifi"); }
From source file:com.microsoft.rightsmanagement.sampleapp.App.java
/** * Dismiss progress dialog./*w ww .jav a2 s . co m*/ */ public static void dismissProgressDialog(FragmentManager supportedFragmentManager) { DialogFragment previous = (ProgressDialogFragment) supportedFragmentManager .findFragmentByTag(ProgressDialogFragment.TAG); if (previous != null) { previous.dismissAllowingStateLoss(); } else if (sProgressDialogFragment != null) { // sometimes findFragmentByTag(ProgressDialogFragment.TAG) fails when fragment is still to be shown sProgressDialogFragment.dismissAllowingStateLoss(); } sProgressDialogFragment = null; }