Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:com.zapp.library.merchant.util.PBBAAppUtils.java

/**
 * Set the callback listener for the popup currently displayed (if any). Use this method to reconnect to the popup in case of orientation change. If there is no
 * popup shown then this method has no effect. If the activity implements the {@link PBBAPopupCallback} interface then the popup automatically reconnects
 * to the activity on attach. This method takes precedence over the automatic reconnecting, so if this method has been called with a valid callback listener before
 * the popup is displayed then the callback interface given in this method will be applied on the popup and the callback interface implemented by the activity will
 * be ignored./*from   w w w .  j  ava 2  s  .co m*/
 *
 * @param activity The activity to use.
 * @param callback The callback listener for the popup. The popup keeps {@link java.lang.ref.WeakReference} to the callback.
 * @return True if the callback is set (the popup is displayed), false otherwise.
 * @see #showPBBAPopup(FragmentActivity, String, String, PBBAPopupCallback)
 * @see #showPBBAErrorPopup(FragmentActivity, String, String, String, PBBAPopupCallback)
 */
@SuppressWarnings({ "BooleanMethodNameMustStartWithQuestion", "ElementOnlyUsedFromTestCode",
        "UnusedReturnValue" })
public static boolean setPBBAPopupCallback(@NonNull final FragmentActivity activity,
        @NonNull final PBBAPopupCallback callback) {

    verifyActivity(activity);

    //noinspection ConstantConditions
    if (callback == null) {
        throw new IllegalArgumentException("callback == null");
    }

    final FragmentManager fragmentManager = activity.getSupportFragmentManager();
    final PBBAPopup fragment = (PBBAPopup) fragmentManager.findFragmentByTag(PBBAPopup.TAG);
    if (fragment != null) {
        fragment.setCallback(callback);
        return true;
    }

    return false;
}

From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuth.java

public static void openDialog(FragmentActivity fragment, String profileID) {
    if (showingDialog) {
        return;/*from ww  w. j av a  2  s .c o m*/
    }
    if (fragment.isFinishing()) {
        return;
    }
    DialogFragmentRcmAuth dlg = new DialogFragmentRcmAuth();
    Bundle bundle = new Bundle();
    bundle.putString(SessionInfoManager.BUNDLE_KEY, profileID);
    dlg.setArguments(bundle);
    showingDialog = true;
    if (!AndroidUtils.showDialog(dlg, fragment.getSupportFragmentManager(), TAG)) {
        showingDialog = false;
    }
}

From source file:org.solovyev.android.messenger.users.CompositeUserDialogFragment.java

public static void show(@Nonnull User contact, @Nonnull ContactUiEventType nextEventType,
        @Nonnull FragmentActivity activity) {
    final CompositeUserDialogFragment fragment = new CompositeUserDialogFragment(contact);

    final Bundle args = new Bundle();
    args.putParcelable(ARG_USER_ENTITY, contact.getEntity());
    args.putSerializable(ARG_NEXT_EVENT_TYPE, nextEventType);
    fragment.setArguments(args);//from  ww w .ja va  2  s.  co m

    Fragments.showDialog(fragment, CompositeUserDialogFragment.FRAGMENT_TAG,
            activity.getSupportFragmentManager());
}

From source file:org.adaway.helper.OpenHelper.java

/**
 * Open default app for opening plain text files
 *
 * @param activity/*w ww . j  a  va2 s .c om*/
 * @param file
 */
private static void openFileWithEditor(final FragmentActivity activity, String file) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri uri = Uri.parse("file://" + file);
    intent.setDataAndType(uri, "text/plain");

    try {
        activity.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        ActivityNotFoundDialogFragment notFoundDialog = ActivityNotFoundDialogFragment.newInstance(
                R.string.no_text_editor_title, R.string.no_text_editor,
                "market://details?id=jp.sblo.pandora.jota", "Text Edit");

        notFoundDialog.show(activity.getSupportFragmentManager(), "notFoundDialog");
    }
}

From source file:com.egoists.coco_nut.android.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  ww  .j a  v  a2  s  . c  o m*/
 * 
 * @param activity The calling {@link FragmentActivity}
 * @param cacheParams The cache parameters to use if creating the ImageCache
 * @return An existing retained ImageCache object or a new one if one did
 *         not exist
 */
public static ImageCache findOrCreateCache(final FragmentActivity activity, ImageCacheParams cacheParams) {

    // Search for, or create an instance of the non-UI RetainFragment
    final RetainFragment mRetainFragment = findOrCreateRetainFragment(activity.getSupportFragmentManager());

    // See if we already have an ImageCache stored in RetainFragment
    ImageCache imageCache = (ImageCache) mRetainFragment.getObject();

    // No existing ImageCache, create one and store it in RetainFragment
    if (imageCache == null) {
        imageCache = new ImageCache(activity, cacheParams);
        mRetainFragment.setObject(imageCache);
    }

    return imageCache;
}

From source file:fi.aalto.displayingbitmaps.util.ImageFetcher.java

public static ImageFetcher createImageFetcher(FragmentActivity context, int thumbSize) {
    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(context, IMAGE_CACHE_DIR);

    // Set memory cache to 25% of app memory
    cacheParams.setMemCacheSizePercent(0.7f);

    ImageFetcher fetcher = new ImageFetcher(context, thumbSize);
    fetcher.setLoadingImage(R.drawable.empty_photo);
    fetcher.addImageCache(context.getSupportFragmentManager(), cacheParams);

    return fetcher;
}

From source file:com.andryr.musicplayer.utils.NavigationUtils.java

@SuppressLint("NewApi")
public static void showFragment(FragmentActivity activity, Fragment firstFragment, Fragment secondFragment,
        @Nullable Pair<View, String>... transitionViews) {

    boolean lollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;

    if (lollipop) {
        firstFragment.setSharedElementReturnTransition(
                TransitionInflater.from(activity).inflateTransition(R.transition.change_image_transform));
        secondFragment.setSharedElementEnterTransition(
                TransitionInflater.from(activity).inflateTransition(R.transition.change_image_transform));
    }//from   w w w  .  ja  v  a  2  s  .c o m
    FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction()
            .replace(R.id.container, secondFragment).addToBackStack(null);
    if (lollipop && transitionViews != null) {

        for (Pair<View, String> tr : transitionViews) {
            ft.addSharedElement(tr.first, tr.second);
        }
    }
    ft.commit();
}

From source file:net.simonvt.cathode.ui.dialog.CheckInDialog.java

public static void showDialogIfNecessary(FragmentActivity activity, Type type, String title, long id) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(activity);
    final boolean facebookShare = settings.getBoolean(Settings.PROFILE_CONNECTION_FACEBOOK, false);
    final boolean twitterShare = settings.getBoolean(Settings.PROFILE_CONNECTION_TWITTER, false);
    final boolean tumblrShare = settings.getBoolean(Settings.PROFILE_CONNECTION_TUMBLR, false);

    if (facebookShare || twitterShare || tumblrShare) {
        newInstance(type, title, id).show(activity.getSupportFragmentManager(), DIALOG_TAG);
    } else {// w  w w  . j  a va 2 s  . co m
        Injections injections = new Injections(activity);

        if (type == Type.SHOW) {
            injections.episodeScheduler.checkin(id, null, false, false, false);
        } else {
            injections.movieScheduler.checkin(id, null, false, false, false);
        }
    }
}

From source file:ca.rmen.android.networkmonitor.app.dialog.DialogFragmentFactory.java

/**
 * Show a visible dialog fragment to choose a folder or file
 *///from w ww  .ja  va 2s . c om
public static void showFileChooserDialog(FragmentActivity activity, File initialFolder, boolean foldersOnly,
        int actionId) {
    Log.v(TAG, "showFileChooserDialog");
    Bundle arguments = new Bundle(3);
    arguments.putInt(EXTRA_ACTION_ID, actionId);
    if (initialFolder != null)
        arguments.putSerializable(FileChooserDialogFragment.EXTRA_FILE_CHOOSER_INITIAL_FOLDER, initialFolder);
    arguments.putBoolean(FileChooserDialogFragment.EXTRA_FILE_CHOOSER_FOLDERS_ONLY, foldersOnly);
    FileChooserDialogFragment result = new FileChooserDialogFragment();
    result.setArguments(arguments);
    result.show(activity.getSupportFragmentManager(), FileChooserDialogFragment.class.getSimpleName());
}

From source file:com.tony.selene.dialog.AbDialogUtil.java

/**
 * ???./*from   ww w . ja  va  2 s  .c o m*/
 * 
 * @param view
 */
public static void showDialog(Context context, DialogFragment fragment) {
    FragmentActivity activity = (FragmentActivity) context;
    fragment.show(activity.getSupportFragmentManager(), dialogTag);
}