Java Code Examples for android.app.FragmentTransaction#detach()
The following examples show how to use
android.app.FragmentTransaction#detach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentTabHost.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public void addTab(android.widget.TabHost.TabSpec tabspec, Class class1, Bundle bundle) { tabspec.setContent(new h(c)); String s = tabspec.getTag(); j j1 = new j(s, class1, bundle); if (h) { j.a(j1, d.findFragmentByTag(s)); if (j.a(j1) != null && !j.a(j1).isDetached()) { FragmentTransaction fragmenttransaction = d.beginTransaction(); fragmenttransaction.detach(j.a(j1)); fragmenttransaction.commit(); } } a.add(j1); addTab(tabspec); }
Example 2
Source File: FragmentTabHost.java From V.FlyoutTest with MIT License | 6 votes |
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(); } } mTabs.add(info); addTab(tabSpec); }
Example 3
Source File: FragmentTabs.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) { mActivity = activity; mTag = tag; mClass = clz; mArgs = args; // 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. mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag); if (mFragment != null && !mFragment.isDetached()) { FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction(); ft.detach(mFragment); ft.commit(); } }
Example 4
Source File: FragmentTabHost.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
protected void onAttachedToWindow() { super.onAttachedToWindow(); String s = getCurrentTabTag(); FragmentTransaction fragmenttransaction = null; int i = 0; while (i < a.size()) { j j1 = (j)a.get(i); j.a(j1, d.findFragmentByTag(j.b(j1))); if (j.a(j1) != null && !j.a(j1).isDetached()) { if (j.b(j1).equals(s)) { g = j1; } else { if (fragmenttransaction == null) { fragmenttransaction = d.beginTransaction(); } fragmenttransaction.detach(j.a(j1)); } } i++; } h = true; FragmentTransaction fragmenttransaction1 = a(s, fragmenttransaction); if (fragmenttransaction1 != null) { fragmenttransaction1.commit(); d.executePendingTransactions(); } }
Example 5
Source File: FragmentTabHost.java From V.FlyoutTest with MIT License | 5 votes |
@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); 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(); } }
Example 6
Source File: FragmentTabHost.java From V.FlyoutTest with MIT License | 5 votes |
private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) { TabInfo newTab = null; 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; }
Example 7
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (mFragment != null) { ft.setCustomAnimations(android.R.animator.fade_in, R.animator.test); ft.detach(mFragment); } }
Example 8
Source File: ArrayPagerAdapter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void detach(Fragment fragment, FragmentTransaction currTransaction) { currTransaction.detach(fragment); }
Example 9
Source File: FragmentTabHost.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
private FragmentTransaction a(String s, FragmentTransaction fragmenttransaction) { j j1 = null; int i = 0; while (i < a.size()) { j j2 = (j)a.get(i); if (!j.b(j2).equals(s)) { j2 = j1; } i++; j1 = j2; } if (j1 == null) { throw new IllegalStateException((new StringBuilder()).append("No tab known for tag ").append(s).toString()); } if (g != j1) { if (fragmenttransaction == null) { fragmenttransaction = d.beginTransaction(); } if (g != null && j.a(g) != null) { fragmenttransaction.detach(j.a(g)); } if (j1 != null) { if (j.a(j1) == null) { j.a(j1, Fragment.instantiate(c, j.c(j1).getName(), j.d(j1))); fragmenttransaction.add(e, j.a(j1), j.b(j1)); } else { fragmenttransaction.attach(j.a(j1)); } } g = j1; } return fragmenttransaction; }
Example 10
Source File: TabListener.java From adapter-kit with Apache License 2.0 | 4 votes |
public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (mFragment != null) { // Detach the fragment, because another one is being attached ft.detach(mFragment); } }
Example 11
Source File: FragmentTabs.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (mFragment != null) { ft.detach(mFragment); } }
Example 12
Source File: ArrayPagerAdapter.java From cwac-pager with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void detach(Fragment fragment, FragmentTransaction currTransaction) { currTransaction.detach(fragment); }