Example usage for android.support.v4.app FragmentManager findFragmentByTag

List of usage examples for android.support.v4.app FragmentManager findFragmentByTag

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager findFragmentByTag.

Prototype

public abstract Fragment findFragmentByTag(String tag);

Source Link

Document

Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.

Usage

From source file:com.cls.sugutomo.map.GooglePlayServicesErrorDialogFragment.java

public static void removeDialog(FragmentActivity activity) {
    FragmentManager fm = activity.getSupportFragmentManager();
    Fragment f = fm.findFragmentByTag(TAG);
    if (f != null) {
        fm.beginTransaction().remove(f).commit();
    }//from  ww w .j a  v  a2  s  . c om
}

From source file:com.meiste.greg.ptw.tab.QuestionsConnectFail.java

public static QuestionsConnectFail getInstance(final FragmentManager fm, final String tag) {
    QuestionsConnectFail f = (QuestionsConnectFail) fm.findFragmentByTag(tag);
    if (f == null) {
        f = new QuestionsConnectFail();
    }//from  w  w  w.java  2s .co  m
    return f;
}

From source file:com.meiste.greg.ptw.tab.QuestionsNotYet.java

public static QuestionsNotYet getInstance(final FragmentManager fm, final Race race) {
    QuestionsNotYet f = (QuestionsNotYet) fm.findFragmentByTag(getTag(race));
    if (f == null) {
        f = new QuestionsNotYet();

        final Bundle args = new Bundle();
        args.putInt(RACE_ID, race.getId());
        f.setArguments(args);//from w  w  w . ja va2s  .  c o  m
    }

    return f;
}

From source file:com.bushstar.htmlcoin_android_wallet.ui.ProgressDialogFragment.java

public static void dismissProgress(final FragmentManager fm) {
    final DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(FRAGMENT_TAG);
    fragment.dismiss();//from   w  w w .ja  v  a2 s .  c o  m
}

From source file:com.microsoft.mimickeralarm.utilities.SettingsUtilities.java

public static AlarmSettingsFragment getAlarmSettingsFragment(FragmentManager fragmentManager) {
    return (AlarmSettingsFragment) fragmentManager
            .findFragmentByTag(AlarmSettingsFragment.SETTINGS_FRAGMENT_TAG);
}

From source file:Main.java

public static void showDialog(@Nonnull DialogFragment dialogFragment, @Nonnull String fragmentTag,
        @Nonnull FragmentManager fm) {
    final FragmentTransaction ft = fm.beginTransaction();

    Fragment prev = fm.findFragmentByTag(fragmentTag);
    if (prev != null) {
        ft.remove(prev);/*from   w  w w  . j av a 2s .c  o m*/
    }

    // Create and show the dialog.
    dialogFragment.show(ft, fragmentTag);
}

From source file:com.microsoft.mimickeralarm.utilities.SettingsUtilities.java

public static MimicsSettingsFragment getMimicsSettingsFragment(FragmentManager fragmentManager) {
    return (MimicsSettingsFragment) fragmentManager
            .findFragmentByTag(MimicsSettingsFragment.MIMICS_SETTINGS_FRAGMENT_TAG);
}

From source file:com.github.mkjensen.dml.util.LoadingHelper.java

private static LoadingFragment getLoadingFragment(FragmentManager fragmentManager) {
    return (LoadingFragment) fragmentManager.findFragmentByTag(LOADING_FRAGMENT_TAG);
}

From source file:Main.java

/**
 * Get a fragment in a {@link ViewPager}s adapter.
 *
 * @param manager//w w  w  .  ja  v a  2s  . c  o m
 *     the support fragment manager.
 *     {@link android.support.v4.app.FragmentActivity#getSupportFragmentManager()}
 * @param pager
 *     the {@link ViewPager} holding the {@link android.support.v4.app.Fragment}
 * @param position
 *     the position in the {@link ViewPager} e.g. {@link ViewPager#getCurrentItem()}
 * @param <fragment>
 *     Destination cast class type.
 * @return the fragment at this position in the {@link ViewPager}'s adapter
 */
@SuppressWarnings("unchecked")
public static <fragment extends android.support.v4.app.Fragment> fragment findFragmentByPosition(
        android.support.v4.app.FragmentManager manager, ViewPager pager, int position) {
    return (fragment) manager
            .findFragmentByTag(String.format(Locale.US, FRAGMENT_ADAPTER_ID, pager.getId(), position));
}

From source file:com.krpiotrek.retainfragment.retainFragment.RetainFragmentHelper.java

/**
 * @return @Nullable RetainFragment. Keep in mind, even if fragment has been set, system may
 * remove it from memory at arbitrary time.
 *//*from w w w .  j  ava 2  s . c om*/
@Nullable
private static <T> RetainFragment<T> getInstance(FragmentManager fragmentManager, String tag) {
    //noinspection unchecked
    return (RetainFragment<T>) fragmentManager.findFragmentByTag(tag);
}