List of usage examples for android.support.v4.app FragmentTransaction commitAllowingStateLoss
public abstract int commitAllowingStateLoss();
From source file:com.sim2dial.dialer.InCallActivity.java
private void replaceFragmentVideoByAudio() { audioCallFragment = new AudioCallFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragmentContainer, audioCallFragment); try {/* w w w .j ava 2 s . c o m*/ transaction.commitAllowingStateLoss(); } catch (Exception e) { } }
From source file:com.sim2dial.dialer.InCallActivity.java
private void replaceFragmentAudioByVideo() { // Hiding controls to let displayVideoCallControlsIfHidden add them plus // the callback mControlsLayout.setVisibility(View.GONE); switchCamera.setVisibility(View.INVISIBLE); videoCallFragment = new VideoCallFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragmentContainer, videoCallFragment); try {// w ww .j av a 2 s . c om transaction.commitAllowingStateLoss(); } catch (Exception e) { } }
From source file:org.mythtv.client.ui.BackendStatusFragment.java
@Override public void onConfigurationChanged(Configuration newConfig) { // re- attach the fragment forcing the view to be recreated. Fragment currentFragment = getFragmentManager().findFragmentByTag(BACKEND_STATUS_FRAGMENT_NAME); if (null != currentFragment) { FragmentTransaction fragTransaction = getFragmentManager().beginTransaction(); fragTransaction.detach(currentFragment); fragTransaction.attach(currentFragment); //TODO: BandAid, not intended as a long term solution. This method needs to be refactored in a way that allows // for a clean commit of the fragment transaction. Fragment transactions should not be performed in // asynchronous framework methods as the activity could be terminated at any time for any reason. fragTransaction.commitAllowingStateLoss(); }/*from ww w . j a va 2 s . c o m*/ super.onConfigurationChanged(newConfig); }
From source file:com.common.base.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);/*from ww w . j a v a 2s. co m*/ tab.fragment = mFragmentManager.findFragmentByTag(tab.tag); // if (tab.fragment != null && !tab.fragment.isDetached()) { if (tab.fragment != null) { 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); ft.hide(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.commitAllowingStateLoss(); mFragmentManager.executePendingTransactions(); } }
From source file:cn.bproject.neteasynews.widget.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);/* www . j a v a 2 s. co m*/ tab.fragment = mFragmentManager.findFragmentByTag(tab.tag); // if (tab.fragment != null && !tab.fragment.isDetached()) { if (tab.fragment != null) { 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); ft.hide(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.commitAllowingStateLoss(); mFragmentManager.executePendingTransactions(); } }
From source file:com.example.dj0708.androiddemo20151224.custom.CustomFragmentTabHost.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);/*from ww w . j a va 2s.c o m*/ 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); ft.hide(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(); ft.commitAllowingStateLoss(); mFragmentManager.executePendingTransactions(); } }
From source file:com.baise.law.widgets.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 av a 2s . c om*/ tab.fragment = mFragmentManager.findFragmentByTag(tab.tag); // if (tab.fragment != null && !tab.fragment.isDetached()) { if (tab.fragment != null) { 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); ft.hide(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.commitAllowingStateLoss(); mFragmentManager.executePendingTransactions(); } }
From source file:com.hippo.scene.StageActivity.java
private void finishScene(String tag, TransitionHelper transitionHelper) { FragmentManager fragmentManager = getSupportFragmentManager(); // Get scene//from w w w. j av a 2s . co m Fragment scene = fragmentManager.findFragmentByTag(tag); if (scene == null) { Log.e(TAG, "finishScene: Can't find scene by tag: " + tag); return; } // Get scene index int index = mSceneTagList.indexOf(tag); if (index < 0) { Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag); return; } if (mSceneTagList.size() == 1) { // It is the last fragment, finish Activity now Log.i(TAG, "finishScene: It is the last scene, finish activity now"); finish(); return; } Fragment next = null; if (index == mSceneTagList.size() - 1) { // It is first fragment, show the next one next = fragmentManager.findFragmentByTag(mSceneTagList.get(index - 1)); } FragmentTransaction transaction = fragmentManager.beginTransaction(); if (next != null) { if (transitionHelper == null || !transitionHelper.onTransition(this, transaction, scene, next)) { // Clear shared item scene.setSharedElementEnterTransition(null); scene.setSharedElementReturnTransition(null); scene.setEnterTransition(null); scene.setExitTransition(null); next.setSharedElementEnterTransition(null); next.setSharedElementReturnTransition(null); next.setEnterTransition(null); next.setExitTransition(null); // Do not show animate if it is not the first fragment transaction.setCustomAnimations(R.anim.scene_close_enter, R.anim.scene_close_exit); } // Attach fragment transaction.attach(next); } transaction.remove(scene); transaction.commitAllowingStateLoss(); // Remove tag mSceneTagList.remove(index); // Return result if (scene instanceof SceneFragment) { ((SceneFragment) scene).returnResult(this); } }
From source file:org.linphone.InCallActivity.java
private void replaceFragmentAudioByVideo() { // Hiding controls to let displayVideoCallControlsIfHidden add them plus the callback mControlsLayout.setVisibility(View.GONE); switchCamera.setVisibility(View.INVISIBLE); videoCallFragment = new VideoCallFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragmentContainer, videoCallFragment); try {/* ww w . j ava2s . c om*/ transaction.commitAllowingStateLoss(); } catch (Exception e) { } }
From source file:org.xingjitong.InCallActivity.java
private void replaceFragmentAudioByVideo() { // Hiding controls to let displayVideoCallControlsIfHidden add them plus // the callback mControlsLayout.setVisibility(View.GONE); switchCamera.setVisibility(View.INVISIBLE); // videoCallFragment = new VideoCallFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // transaction.replace(R.id.fragmentContainer, videoCallFragment); try {//from w ww.j av a 2 s .co m transaction.commitAllowingStateLoss(); } catch (Exception e) { } }