Example usage for android.app FragmentManager beginTransaction

List of usage examples for android.app FragmentManager beginTransaction

Introduction

In this page you can find the example usage for android.app FragmentManager beginTransaction.

Prototype

public abstract FragmentTransaction beginTransaction();

Source Link

Document

Start a series of edit operations on the Fragments associated with this FragmentManager.

Usage

From source file:com.example.hello.mymap.util.ImageCache.java

/**
 * Locate an existing instance of this Fragment or if not found, create and
 * add it using FragmentManager./*w w w  . j  ava 2s .c  o m*/
 * 
 * @param fm
 *            The FragmentManager manager to use.
 * @return The existing instance of the Fragment or the new instance if just
 *         created.
 */
private static RetainFragment findOrCreateRetainFragment(FragmentManager fm) {
    // BEGIN_INCLUDE(find_create_retain_fragment)
    // Check to see if we have retained the worker fragment.
    RetainFragment mRetainFragment = (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;
    // END_INCLUDE(find_create_retain_fragment)
}

From source file:com.afrozaar.jazzfestreporting.util.ImageCache.java

/**
 * Locate an existing instance of this Fragment or if not found, create and
 * add it using FragmentManager.//www  . j  a  v  a  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 RetainFragment findOrCreateRetainFragment(FragmentManager fm) {
    // Check to see if we have retained the worker fragment.
    RetainFragment mRetainFragment = (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;
}

From source file:net.bither.image.cache.ImageCache.java

/**
 * Locate an existing instance of this Fragment or if not found, create and
 * add it using FragmentManager./*from w w  w  . j a  v  a2 s .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 = (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;
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

public static void add(FragmentManager fm, SettingsLayoutFragment f) {
    boolean hasDialog = fm.findFragmentByTag(TAG_LEAN_BACK_DIALOG_FRAGMENT) != null;
    FragmentTransaction ft = fm.beginTransaction();

    if (hasDialog) {
        ft.setCustomAnimations(ANIMATION_FRAGMENT_ENTER, ANIMATION_FRAGMENT_EXIT, ANIMATION_FRAGMENT_ENTER_POP,
                ANIMATION_FRAGMENT_EXIT_POP);
        ft.addToBackStack(null);// w  w w  .  ja  va 2s  .c o m
    }
    ft.replace(android.R.id.content, f, TAG_LEAN_BACK_DIALOG_FRAGMENT).commit();
}

From source file:com.android.fragmentbase.cache.ImageCache.java

/**
 * Locate an existing instance of this Fragment or if not found, create and
 * add it using FragmentManager./* ww  w.  j a  v  a2s.c  om*/
 *
 * @param fm The FragmentManager manager to use.
 * @return The existing instance of the Fragment or the new instance if just
 * created.
 */
private static RetainFragment findOrCreateRetainFragment(FragmentManager fm) {
    // Check to see if we have retained the worker fragment.
    RetainFragment mRetainFragment = (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;
}

From source file:at.fjp.cards.ImageCache.java

/**
 * Locate an existing instance of this Fragment or if not found, create and
 * add it using FragmentManager./*  w  w w  .  j  a va2  s  . com*/
 *
 * @param fm The FragmentManager manager to use.
 * @return The existing instance of the Fragment or the new instance if just
 *         created.
 */
private static RetainFragment findOrCreateRetainFragment(FragmentManager fm) {
    //BEGIN_INCLUDE(find_create_retain_fragment)
    // Check to see if we have retained the worker fragment.
    RetainFragment mRetainFragment = (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;
    //END_INCLUDE(find_create_retain_fragment)
}

From source file:jp.co.rediscovery.arflight.ManagerFragment.java

/**
 * ManagerFragment??//w ww.ja v  a2 s.  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.boko.vimusic.cache.ImageCache.java

/**
 * Locate an existing instance of this {@link Fragment} or if not found,
 * create and add it using {@link FragmentManager}
 * // w w w .j av a  2  s .c  o m
 * @param fm
 *            The {@link FragmentManager} to use
 * @return The existing instance of the {@link Fragment} or the new instance
 *         if just created
 */
public static final RetainFragment findOrCreateRetainFragment(final FragmentManager fm) {
    // Check to see if we have retained the worker fragment
    RetainFragment retainFragment = (RetainFragment) fm.findFragmentByTag(TAG);

    // If not retained, we need to create and add it
    if (retainFragment == null) {
        retainFragment = new RetainFragment();
        fm.beginTransaction().add(retainFragment, TAG).commit();
    }
    return retainFragment;
}

From source file:com.yahoo.android.search.showcase.SearchDemoActivity.java

@Override
public void onNavigationDrawerItemSelected(int position, String title) {

    // Get the corresponding fragment to display from the Fragment factory
    Fragment demoFragment = SearchDemoFragmentFactory.getFragment(position);
    mTitle = title;//from   ww w .j  a  va 2s. c o m

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.container, demoFragment).commit();
}

From source file:net.callmeike.android.mojowire.ui.MainActivity.java

@Override
public void onPodcastSelected(int id, String episodeTitle) {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.container, EpisodeFragment.newInstance(id, episodeTitle))
            .commit();//from w w  w. j  av a2s.co  m
}