Example usage for android.app FragmentTransaction detach

List of usage examples for android.app FragmentTransaction detach

Introduction

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

Prototype

public abstract FragmentTransaction detach(Fragment fragment);

Source Link

Document

Detach the given fragment from the UI.

Usage

From source file:es.farfuteam.vncpp.controller.TabListener.java

/**
 * @param tab/* w  w  w.j a v a  2  s.com*/
 * @param ft
 * @brief Method called when the tab is unselected
 * @details Method called when the tab is unselected
 */
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {

    if (mFragment != null) {
        // Detach the fragment, because another one is being attached
        ft.detach(mFragment);
    }

}

From source file:android.support.v13.app.FragmentTabHost.java

public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(mContext));
    String tag = tabSpec.getTag();

    TabInfo info = new TabInfo(tag, clss, args);

    if (mAttached) {
        // If we are already attached to the window, then check to make
        // sure this tab's fragment is inactive if it exists.  This shouldn't
        // normally happen.
        info.fragment = mFragmentManager.findFragmentByTag(tag);
        if (info.fragment != null && !info.fragment.isDetached()) {
            FragmentTransaction ft = mFragmentManager.beginTransaction();
            ft.detach(info.fragment);
            ft.commit();/*www  .j  a  v a 2 s .c  om*/
        }
    }

    mTabs.add(info);
    addTab(tabSpec);
}

From source file:com.bct.gpstracker.util.FragmentTabHost.java

public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(mContext));
    String tag = tabSpec.getTag();

    TabInfo info = new TabInfo(tag, clss, args);

    if (mAttached) {
        // If we are already attached to the window, then check to make
        // sure this tab's fragment is inactive if it exists.  This shouldn't
        // normally happen.
        info.fragment = mFragmentManager.findFragmentByTag(tag);
        if (info.fragment != null && !info.fragment.isDetached()) {
            FragmentTransaction ft = mFragmentManager.beginTransaction();
            ft.detach(info.fragment);
            ft.commit();/*w w  w  .  j a  v a2s.  co  m*/
        }
    }

    mTabs.add(info);
    addTab(tabSpec);
}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void detachPanel(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.detach(p);
    fragmentTransaction.commit();/*from   w ww  . jav a2s.  c  o m*/

    panelCount--;
}

From source file:android.support.v13.app.FragmentTabHost.java

private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) {
    TabInfo newTab = null;/*from w w  w  . j  ava  2  s .  com*/
    for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);
        if (tab.tag.equals(tabId)) {
            newTab = tab;
        }
    }
    if (newTab == null) {
        throw new IllegalStateException("No tab known for tag " + tabId);
    }
    if (mLastTab != newTab) {
        if (ft == null) {
            ft = mFragmentManager.beginTransaction();
        }
        if (mLastTab != null) {
            if (mLastTab.fragment != null) {
                ft.detach(mLastTab.fragment);
            }
        }
        if (newTab != null) {
            if (newTab.fragment == null) {
                newTab.fragment = Fragment.instantiate(mContext, newTab.clss.getName(), newTab.args);
                ft.add(mContainerId, newTab.fragment, newTab.tag);
            } else {
                ft.attach(newTab.fragment);
            }
        }

        mLastTab = newTab;
    }
    return ft;
}

From source file:at.flack.MainActivity.java

public void redrawFbFragment() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.detach(FacebookMainActivity.getInstance());
    ft.commit();
}

From source file:at.flack.MainActivity.java

public void redrawMailFragment() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.detach(MailMainActivity.getInstance());
    ft.commit();
}

From source file:android.support.v13.app.FragmentTabHost.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    String currentTab = getCurrentTabTag();

    // Go through all tabs and make sure their fragments match
    // the correct state.
    FragmentTransaction ft = null;
    for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);/*w w  w  .j a  v  a  2s . c  om*/
        tab.fragment = mFragmentManager.findFragmentByTag(tab.tag);
        if (tab.fragment != null && !tab.fragment.isDetached()) {
            if (tab.tag.equals(currentTab)) {
                // The fragment for this tab is already there and
                // active, and it is what we really want to have
                // as the current tab.  Nothing to do.
                mLastTab = tab;
            } else {
                // This fragment was restored in the active state,
                // but is not the current tab.  Deactivate it.
                if (ft == null) {
                    ft = mFragmentManager.beginTransaction();
                }
                ft.detach(tab.fragment);
            }
        }
    }

    // We are now ready to go.  Make sure we are switched to the
    // correct tab.
    mAttached = true;
    ft = doTabChanged(currentTab, ft);
    if (ft != null) {
        ft.commit();
        mFragmentManager.executePendingTransactions();
    }
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Detach panel from view./*w w  w.j  a va  2  s .co  m*/
 */
public void detachPanel(SplitPanel p) {
    Log.d(LOG, "ReaderActivity.detachPanel");

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.detach(p);
    fragmentTransaction.commit();

    panelCount--;
}