Example usage for android.support.v4.app FragmentTransaction detach

List of usage examples for android.support.v4.app FragmentTransaction detach

Introduction

In this page you can find the example usage for android.support.v4.app FragmentTransaction detach.

Prototype

public abstract FragmentTransaction detach(Fragment fragment);

Source Link

Document

Detach the given fragment from the UI.

Usage

From source file:net.globide.creepypasta_files_07.BrowseActivity.java

/**
 * Detaches the fragments if necessary as they are being added to the
 * hashmap./*from  w w w .  ja  va2 s.c  o  m*/
 */
private static void addFrag(BrowseActivity activity, FragInfo fiNewFrag, String tag) {
    // Check to see if we already have a fragment created, probably
    // from a previously saved state. If so, deactivate it, because our
    // initial state is that a frag isn't being shown.
    fiNewFrag.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);

    if (fiNewFrag.fragment != null && !fiNewFrag.fragment.isDetached()) {
        // If a fragment was previously created and it is currently
        // attached,
        // begin a fragment transaction.
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        // Detach the fragment.
        ft.detach(fiNewFrag.fragment);

        // Commit transaction changes.
        ft.commit();
        // Execute the transaction.
        activity.getSupportFragmentManager().executePendingTransactions();
    }
}

From source file:net.globide.creepypasta_files_07.BookmarksActivity.java

/**
 * Detaches the fragments if necessary as they are being added to the
 * hashmap./*from  ww w.j  a  v  a 2 s . c  o m*/
 */
private static void addFrag(BookmarksActivity activity, FragInfo fiNewFrag, String tag) {
    // Check to see if we already have a fragment created, probably
    // from a previously saved state. If so, deactivate it, because our
    // initial state is that a frag isn't being shown.
    fiNewFrag.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);

    if (fiNewFrag.fragment != null && !fiNewFrag.fragment.isDetached()) {
        // If a fragment was previously created and it is currently
        // attached,
        // begin a fragment transaction.
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        // Detach the fragment.
        ft.detach(fiNewFrag.fragment);

        // Commit transaction changes.
        ft.commit();
        // Execute the transaction.
        activity.getSupportFragmentManager().executePendingTransactions();
    }
}

From source file:com.ubundude.timesheet.MainActivity.java

private static void addTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    String tag = tabSpec.getTag();

    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
    if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        ft.detach(tabInfo.fragment);
        ft.commit();//from  w  w w  .  ja  v  a  2s  .  com
        activity.getSupportFragmentManager().executePendingTransactions();
    }

    tabHost.addTab(tabSpec);
}

From source file:com.yallaya.fragments.FragmentsModule.java

public static void s_detach(Object arg) {

    HashMap<String, Object> options = (HashMap) arg;

    if (!options.containsKey("fragment")) {
        Log.w(LCAT, "detach called without the fragment arrgument");
        return;/*  w ww.  ja va2s.c  o  m*/
    }

    FragmentProxy proxy = (FragmentProxy) options.get("fragment");
    Fragment frg = proxy.fragment;

    if (frg.isDetached()) {
        Log.w(LCAT, "fragment has already been detached");
        return;
    }

    FragmentTransaction ft = getTransaction(options);
    ft.detach(frg);
    ft.commit();
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

/**
 * @param activity;/*from   ww  w.  j  av  a  2  s.  co m*/
 * @param tabHost;
 * @param tabSpec;
 */
private static void addTab(ViewRedditActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec,
        TabInfo tabInfo) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    String tag = tabSpec.getTag();
    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
    if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
        android.support.v4.app.FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        ft.detach(tabInfo.fragment);
        ft.commit();
        activity.getSupportFragmentManager().executePendingTransactions();
    }

    tabHost.addTab(tabSpec);
}

From source file:com.pytacular.checkitcloudchecklist.TabListener.java

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
    if (mFragment != null) {
        ft.detach(mFragment);
    }/*from   w  w w. j a  v  a 2 s  .com*/
}

From source file:fr.ippon.android.opendata.android.TabListener.java

public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    if (mFragment != null) {
        ft.detach(mFragment);
    }
}

From source file:info.wncwaterfalls.app.TabListener.java

@Override
public void onTabUnselected(Tab tab, FragmentTransaction transaction) {
    if (aFragment != null) {
        transaction.detach(aFragment);
    }/*from ww  w . j a v  a  2  s.  c  o  m*/
}

From source file:org.onebusaway.android.ui.TabListener.java

public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction unused) {
    if (mFragment != null) {
        FragmentManager fm = mActivity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();

        ft.detach(mFragment);

        ft.commit();/*w  ww  .  ja  v  a  2  s  . c  o m*/
    }
}

From source file:can.yrt.onebusaway.TabListener.java

public void onTabUnselected(Tab tab, FragmentTransaction unused) {
    if (mFragment != null) {
        FragmentManager fm = mActivity.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();

        ft.detach(mFragment);

        ft.commit();/*  ww  w .j  a  v  a 2  s  . com*/
    }
}