List of usage examples for android.app Activity getFragmentManager
@Deprecated
public FragmentManager getFragmentManager()
From source file:com.zhangwx.dynamicpermissionsrequest.permission.EasyPermissions.java
/** * Request a set of permissions, showing rationale if the system requests it.0 * * @param activity {@link Activity} requesting permissions. Should implement {@link * ActivityCompat.OnRequestPermissionsResultCallback} or override {@link * FragmentActivity#onRequestPermissionsResult(int, String[], int[])} if * it extends from {@link FragmentActivity}. * @param rationale a message explaining why the application needs this set of permissions, * will be displayed if the user rejects the request the first time. * @param positiveButton custom text for positive button * @param negativeButton custom text for negative button * @param requestCode request code to track this request, must be < 256. * @param perms a set of permissions to be requested. * @see Manifest.permission/* www.j a v a 2 s .com*/ */ @SuppressLint("NewApi") public static void requestPermissions(@NonNull Activity activity, @DrawableRes int icon, String title, @NonNull String rationale, @StringRes int positiveButton, @StringRes int negativeButton, int requestCode, @NonNull String... perms) { if (hasPermissions(activity, perms)) { notifyAlreadyHasPermissions(activity, requestCode, perms); return; } if (shouldShowRationale(activity, perms)) { showRationaleDialogFragment(activity.getFragmentManager(), icon, title, rationale, positiveButton, negativeButton, requestCode, perms); } else { ActivityCompat.requestPermissions(activity, perms, requestCode); } }
From source file:de.spiritcroc.modular_remote.Util.java
public static void addWidgetToContainer(Activity activity, PageContainerFragment page, @Nullable Container container, @Nullable DialogFragment dismissDialog) { if (container == null) { new SelectContainerDialog().addWidget(page).show(activity.getFragmentManager(), "SelectContainerDialog"); } else if (activity instanceof MainActivity) { ((MainActivity) activity).setAddWidgetListener(dismissDialog); ((MainActivity) activity).addWidget(container); } else {// w w w .j a va 2 s . c o m Log.w(LOG_TAG, "addWidgetToContainer: !(activity instanceof MainActivity)"); } }
From source file:de.spiritcroc.modular_remote.Util.java
public static void addFragmentToContainer(Activity activity, @NonNull ModuleFragment fragment, PageContainerFragment page, @Nullable Container container) { if (container == null) { new SelectContainerDialog().setValues(page, fragment).show(activity.getFragmentManager(), "SelectContainerDialog"); } else {//w w w. j a v a 2 s.co m fragment.prepareDepthChange(); container.addFragment(fragment, false); if (activity instanceof MainActivity) { // Scroll to newly added fragment Container parent = fragment instanceof Container ? (Container) fragment : fragment.getParent(); while (parent != null && !(parent instanceof PageContainerFragment) && parent instanceof ModuleFragment) { parent = ((ModuleFragment) parent).getParent(); } if (parent instanceof PageContainerFragment) { ((MainActivity) activity).scrollToPage((PageContainerFragment) parent); } } } }
From source file:com.boko.vimusic.cache.ImageCache.java
/** * Find and return an existing ImageCache stored in a {@link RetainFragment} * , if not found a new one is created using the supplied params and saved * to a {@link RetainFragment}//from w w w .j ava2 s. c o m * * @param activity * The calling {@link FragmentActivity} * @return An existing retained ImageCache object or a new one if one did * not exist */ public static final ImageCache findOrCreateCache(final Activity activity) { // Search for, or create an instance of the non-UI RetainFragment final RetainFragment retainFragment = findOrCreateRetainFragment(activity.getFragmentManager()); // See if we already have an ImageCache stored in RetainFragment ImageCache cache = (ImageCache) retainFragment.getObject(); // No existing ImageCache, create one and store it in RetainFragment if (cache == null) { cache = getInstance(activity); retainFragment.setObject(cache); } return cache; }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void showBreadSignal(Activity activity, String title, String iconDescription, int drawableId, BROnSignalCompletion completion) { fragmentSignal = new FragmentSignal(); Bundle bundle = new Bundle(); bundle.putString(FragmentSignal.TITLE, title); bundle.putString(FragmentSignal.ICON_DESCRIPTION, iconDescription); fragmentSignal.setCompletion(completion); bundle.putInt(FragmentSignal.RES_ID, drawableId); fragmentSignal.setArguments(bundle); FragmentTransaction transaction = activity.getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_bottom, R.animator.from_bottom, R.animator.to_bottom);/* w w w. j a va 2 s . c o m*/ transaction.add(android.R.id.content, fragmentSignal, fragmentSignal.getClass().getName()); transaction.addToBackStack(null); if (!activity.isDestroyed()) transaction.commit(); }
From source file:com.upnext.blekit.BLEKit.java
private static void showErrorDialog(String msg, Activity activity, boolean bleUnavailable) { ErrorDialogFragment dlg = new ErrorDialogFragment(msg, bleUnavailable); dlg.show(activity.getFragmentManager(), null); }
From source file:com.google.games.bridge.TokenFragment.java
/** * External entry point for getting tokens and email address. This * creates the fragment if needed and queues up the request. The fragment, once * active processes the list of requests. * * @param parentActivity - the activity to attach the fragment to. * @param rationale - the rationale to display when requesting permission. * @param fetchEmail - true indicates get the email. * @param fetchAccessToken - true indicates get the access token. * @param fetchIdToken - true indicates get the id token. * @param scope - the scope for getting the id token. * @return PendingResult for retrieving the results when ready. *///from w ww.ja v a 2 s . co m public static PendingResult fetchToken(Activity parentActivity, String rationale, boolean fetchEmail, boolean fetchAccessToken, boolean fetchIdToken, String scope) { TokenRequest request = new TokenRequest(fetchEmail, fetchAccessToken, fetchIdToken, scope); request.setRationale(rationale); synchronized (pendingTokenRequests) { pendingTokenRequests.add(request); } TokenFragment fragment = (TokenFragment) parentActivity.getFragmentManager() .findFragmentByTag(FRAGMENT_TAG); if (fragment == null) { try { Log.d(TAG, "Creating fragment"); fragment = new TokenFragment(); FragmentTransaction trans = parentActivity.getFragmentManager().beginTransaction(); trans.add(fragment, FRAGMENT_TAG); trans.commit(); } catch (Throwable th) { Log.e(TAG, "Cannot launch token fragment:" + th.getMessage(), th); request.setResult(CommonStatusCodes.ERROR); synchronized (pendingTokenRequests) { pendingTokenRequests.remove(request); } } } else { Log.d(TAG, "Fragment exists.. calling processRequests"); fragment.processRequests(CommonStatusCodes.SUCCESS); } return request.getPendingResponse(); }
From source file:jp.co.rediscovery.arflight.ManagerFragment.java
/** * ManagerFragment??/*from ww w. j a v a 2s . c o m*/ * @param activity * @return */ public static synchronized ManagerFragment getInstance(final Activity activity) { ManagerFragment result = null; if ((activity != null) && !activity.isFinishing()) { final FragmentManager fm = activity.getFragmentManager(); result = (ManagerFragment) fm.findFragmentByTag(TAG); if (result == null) { result = new ManagerFragment(); fm.beginTransaction().add(result, TAG).commit(); } } return result; }
From source file:com.android.tv.dvr.ui.DvrUiHelper.java
private static void showDialogFragment(Activity activity, DvrHalfSizedDialogFragment dialogFragment, Bundle args, boolean keepSidePanelHistory, boolean keepProgramGuide) { dialogFragment.setArguments(args);//from w w w. j av a 2 s . c o m if (activity instanceof MainActivity) { ((MainActivity) activity).getOverlayManager().showDialogFragment(DvrHalfSizedDialogFragment.DIALOG_TAG, dialogFragment, keepSidePanelHistory, keepProgramGuide); } else { dialogFragment.show(activity.getFragmentManager(), DvrHalfSizedDialogFragment.DIALOG_TAG); } }
From source file:com.google.android.gms.common.C0270e.java
public static boolean m3384a(int i, Activity activity, Fragment fragment, int i2, OnCancelListener onCancelListener) { boolean z = false; Dialog b = C0270e.m3391b(i, activity, fragment, i2, onCancelListener); if (b == null) { return z; }//from ww w . ja v a 2 s .c o m try { z = activity instanceof FragmentActivity; } catch (NoClassDefFoundError e) { } if (z) { C0271f.m3400a(b, onCancelListener).show(((FragmentActivity) activity).getSupportFragmentManager(), "GooglePlayServicesErrorDialog"); } else if (C0519x.m4171a()) { C0262b.m3362a(b, onCancelListener).show(activity.getFragmentManager(), "GooglePlayServicesErrorDialog"); } else { throw new RuntimeException("This Activity does not support Fragments."); } return true; }