List of usage examples for android.support.v4.app FragmentTransaction commitAllowingStateLoss
public abstract int commitAllowingStateLoss();
From source file:com.xperia64.timidityae.PlayerFragment.java
public void incrementInterface() { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); fm.beginTransaction();/*from w ww . j av a2 s .c o m*/ if ((!JNIHandler.type) && Globals.isPlaying == 0) { if (++fragMode > 2) fragMode = 0; } else { fragMode = 0; } switch (fragMode) { case 0: artsy = new ArtFragment(); ft.replace(R.id.midiContainer, artsy); ft.commitAllowingStateLoss(); break; case 1: tracky = new TrackFragment(); ft.replace(R.id.midiContainer, tracky); ft.commitAllowingStateLoss(); break; case 2: lyrical = new LyricFragment(); ft.replace(R.id.midiContainer, lyrical); ft.commitAllowingStateLoss(); break; } }
From source file:com.xperia64.timidityae.PlayerFragment.java
public void setInterface(int which) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); fragMode = which;/* ww w.ja va 2s.c o m*/ fm.beginTransaction(); if ((!JNIHandler.type) && Globals.isPlaying == 0) { if (fragMode > 2) fragMode = 0; } else { fragMode = 0; } switch (fragMode) { case 0: artsy = new ArtFragment(); ft.replace(R.id.midiContainer, artsy); ft.commitAllowingStateLoss(); break; case 1: tracky = new TrackFragment(); ft.replace(R.id.midiContainer, tracky); ft.commitAllowingStateLoss(); break; case 2: lyrical = new LyricFragment(); ft.replace(R.id.midiContainer, lyrical); ft.commitAllowingStateLoss(); break; } }
From source file:com.awrtechnologies.carbudgetsales.MainActivity.java
public void openNewFragment(Fragment f) { try {/*from w w w . ja v a2s .co m*/ InputMethodManager input = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); input.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0); } catch (Exception e) { } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); fragmentstack.push(currentfragment); ft.replace(R.id.contanier, f); currentfragment = f; ft.commitAllowingStateLoss(); }
From source file:de.tap.easy_xkcd.Activities.MainActivity.java
private void showFragment(String prefTag, int itemId, String actionBarTitle, String fragmentTagShow, String fragmentTagHide, String fragmentTagHide2, boolean showOverview) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); assert getSupportActionBar() != null; //We always have an ActionBar available, so this stops Android Studio from complaining about possible NullPointerExceptions //Setup FAB//from w w w .j a v a 2 s . c o m if (prefHelper.fabEnabled(prefTag)) { mFab.setVisibility(View.GONE); } else if (!fragmentTagShow.equals(WHATIF_TAG)) { mFab.setVisibility(View.VISIBLE); } else { mFab.setVisibility(View.GONE); } getSupportActionBar().setTitle(actionBarTitle); if (fragmentManager.findFragmentByTag(fragmentTagShow) != null) { //if the fragment exists, show it. android.support.v4.app.FragmentTransaction ft = fragmentManager.beginTransaction(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) fragmentManager.findFragmentByTag(fragmentTagShow).setEnterTransition(null); if (fragmentTagShow.equals(BROWSER_TAG)) { ft.setCustomAnimations(R.anim.abc_slide_in_top, R.anim.abc_slide_in_top); } else { ft.setCustomAnimations(R.anim.abc_slide_in_bottom, R.anim.abc_slide_in_bottom); } ft.show(fragmentManager.findFragmentByTag(fragmentTagShow)); ft.commitAllowingStateLoss(); //Update action bar } else { //if the fragment does not exist, add it to fragment manager. switch (itemId) { case R.id.nav_favorites: fragmentManager.beginTransaction() .setCustomAnimations(R.anim.abc_slide_in_bottom, R.anim.abc_slide_in_bottom) .add(R.id.flContent, new FavoritesFragment(), fragmentTagShow).commitAllowingStateLoss(); break; case R.id.nav_browser: if (prefHelper.isOnline(this) && !fullOffline) { fragmentManager.beginTransaction() .add(R.id.flContent, new ComicBrowserFragment(), fragmentTagShow) .commitAllowingStateLoss(); } else { fragmentManager.beginTransaction().add(R.id.flContent, new OfflineFragment(), fragmentTagShow) .commitAllowingStateLoss(); } break; case R.id.nav_whatif: fragmentManager.beginTransaction() .add(R.id.flContent, new WhatIfOverviewFragment(), fragmentTagShow) .commitAllowingStateLoss(); break; } } if (prefHelper.subtitleEnabled() && itemId != R.id.nav_whatif) { switch (itemId) { //Update Action Bar title case R.id.nav_favorites: { FavoritesFragment favoritesFragment = (FavoritesFragment) getSupportFragmentManager() .findFragmentByTag(FAV_TAG); if (favoritesFragment != null && favoritesFragment.favorites != null) getSupportActionBar().setSubtitle( String.valueOf(favoritesFragment.favorites[favoritesFragment.favoriteIndex])); break; } case R.id.nav_browser: { ComicFragment comicFragment = (ComicFragment) getSupportFragmentManager() .findFragmentByTag(BROWSER_TAG); if (comicFragment != null && comicFragment.lastComicNumber != 0) getSupportActionBar().setSubtitle(String.valueOf(comicFragment.lastComicNumber)); else getSupportActionBar().setSubtitle(String.valueOf(prefHelper.getLastComic())); break; } } } else if (itemId == R.id.nav_whatif) { getSupportActionBar().setSubtitle(""); } if (fragmentManager.findFragmentByTag(fragmentTagHide) != null) fragmentManager.beginTransaction().hide(fragmentManager.findFragmentByTag(fragmentTagHide)) .commitAllowingStateLoss(); if (fragmentManager.findFragmentByTag(fragmentTagHide2) != null) fragmentManager.beginTransaction().hide(fragmentManager.findFragmentByTag(fragmentTagHide2)) .commitAllowingStateLoss(); if (fragmentManager.findFragmentByTag(OVERVIEW_TAG) != null) fragmentManager.beginTransaction().hide(fragmentManager.findFragmentByTag(OVERVIEW_TAG)) .commitAllowingStateLoss(); if (showOverview) showOverview(); }
From source file:com.example.winner.yueshijia.views.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 a2 s. 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.commitAllowingStateLoss(); // // ft.commit(); mFragmentManager.executePendingTransactions(); } }
From source file:com.lh16808.app.lhys.widget.FragmentTabHost2.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 w w w . ja v a2s. 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.commitAllowingStateLoss(); mFragmentManager.executePendingTransactions(); } }
From source file:com.suning.mobile.ebuy.lottery.utils.view.FragmentTabHostAllowLoseState.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 w w w. j a v a 2 s. 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); } } } // 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.supremainc.biostar2.main.HomeActivity.java
/** * 1 depth menu???. stack??? clear/* w ww . j av a 2s .co m*/ * * @param type * @param args */ public void gotoScreen(ScreenType type, Bundle args, boolean skipAni) { if (type == null) { return; } if (activityScreen(type, args)) { return; } switch (type) { case LOG_OUT: logOut(); return; case OPEN_MENU: mLayout.onDrawMenu(); return; default: break; } BaseFragment fragment = createFragement(type, args); if (fragment == null) { if (BuildConfig.DEBUG) { Log.e(TAG, "fragment null gotoScreen:" + type); } mLayout.closeDrawer(); return; } mFragment = fragment; if (BuildConfig.DEBUG) { Log.i(TAG, "gotoScreen:" + type); } FragmentManager fm = getSupportFragmentManager(); for (int i = 0; i < fm.getBackStackEntryCount(); ++i) { fm.popBackStack(); } FragmentTransaction transaction = fm.beginTransaction(); if (!skipAni) { if (type == ScreenType.MAIN) { transaction.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right); } else { transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); } } transaction.replace(R.id.content_frame, mFragment); transaction.commitAllowingStateLoss(); if (type != ScreenType.MAIN) { mHandler.postDelayed(mCloseDrawer, 200); } }
From source file:org.telegram.ui.ApplicationActivity.java
public void presentFragment(BaseFragment fragment, String tag, boolean removeLast, boolean bySwipe) { if (getCurrentFocus() != null) { Utilities.hideKeyboard(getCurrentFocus()); }/*from w w w . jav a2 s . c o m*/ if (!fragment.onFragmentCreate()) { return; } BaseFragment current = null; if (!ApplicationLoader.fragmentsStack.isEmpty()) { current = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 1); } if (current != null) { current.willBeHidden(); } FragmentManager fm = getSupportFragmentManager(); FragmentTransaction fTrans = fm.beginTransaction(); if (removeLast && current != null) { ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1); current.onFragmentDestroy(); } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); boolean animations = preferences.getBoolean("view_animations", true); if (animations) { if (bySwipe) { fTrans.setCustomAnimations(R.anim.slide_left, R.anim.no_anim); } else { fTrans.setCustomAnimations(R.anim.scale_in, R.anim.no_anim); } } fTrans.replace(R.id.container, fragment, tag); fTrans.commitAllowingStateLoss(); ApplicationLoader.fragmentsStack.add(fragment); }
From source file:com.gitstudy.fragmenttabhostutils.huihuituijian.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 . ja va 2 s. 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(); } }