List of usage examples for android.support.v4.app FragmentTransaction commitAllowingStateLoss
public abstract int commitAllowingStateLoss();
From source file:org.mythdroid.activities.Recordings.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (icicle != null) { checkedIndex = icicle.getInt("checkedIndex"); //$NON-NLS-1$ visibleIndex = icicle.getInt("visibleIndex"); //$NON-NLS-1$ filter = icicle.getString("filter"); //$NON-NLS-1$ }// ww w. j ava 2s . c o m setContentView(R.layout.recordings); listFragment = new RecListFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.reclistframe, listFragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commitAllowingStateLoss(); }
From source file:com.mubaloo.org.activity.MubalooActivity.java
/** * <p>/*from w w w . j a v a 2s.c o m*/ * Replace any fragment, and save the fragment on the stack for future use * Accept contentfragment as fragment, id of the layout, to replace anim = * true, will have visual animation effect, anim = false, will replace * without any animation * </p> * */ private int replaceFragment(Fragment contentfragment, int layout, boolean anim) { int result = 0; try { FragmentTransaction transaction = fragmentmanager.beginTransaction(); if (anim) { transaction.setCustomAnimations(android.R.anim.slide_out_right, android.R.anim.slide_in_left); transaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right); } transaction.replace(layout, contentfragment); transaction.addToBackStack(null); result = transaction.commitAllowingStateLoss(); getSupportFragmentManager().executePendingTransactions(); stack.push(contentfragment); } catch (Exception e) { Logger.e(Mubaloo.TAG.toString(), e.toString() + ""); e.printStackTrace(); } return result; }
From source file:com.robotsandpencils.walkthrough.presentation.common.Navigator.java
public void showPagerFragment(FragmentManager fragmentManager, List<Page> pageList, LayoutTheme layoutTheme) { pushPageList(pageList);/*from w w w.j ava2 s. c o m*/ mPagerFragment = PagerFragment.newInstance(layoutTheme); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(layoutTheme.getPageListEnterAnimation(), layoutTheme.getPageListExitAnimation(), layoutTheme.getPageListPopEnterAnimation(), layoutTheme.getPageListPopExitAnimation()); fragmentTransaction.replace(R.id.fragment_container, mPagerFragment, TAG_PAGER_FRAGMENT + mCounter.next()); fragmentTransaction.addToBackStack(TAG_PAGER_FRAGMENT + mCounter.current()); fragmentTransaction.commitAllowingStateLoss(); }
From source file:com.github.fi3te.iliasdownloader.view.IliasActivity.java
@Override public void coursesLoaded(TwoObjectsX<List<Long>, List<String>> coursesWithNames) { FragmentManager fm = getSupportFragmentManager(); Fragment task = fm.findFragmentByTag(TASK_FRAGMENT_TAG); FragmentTransaction ft = fm.beginTransaction(); ft.remove(task);/* ww w.jav a 2s . c o m*/ ft.commitAllowingStateLoss(); fm.executePendingTransactions(); final List<Long> courses = coursesWithNames.getObjectA(); List<String> courseNames = coursesWithNames.getObjectB(); IliasProperties properties = IliasPropertiesUtil.readIliasProperties(this); Set<Long> activeCourses = properties.getActiveCourses(); final CharSequence[] items = new CharSequence[courses.size()]; for (int i = 0; i < courses.size(); i++) { items[i] = courseNames.get(i); } /* * Selected indices * | * V */ List<Integer> selectedIndicesList = new LinkedList<Integer>(); if (properties.isSyncAll()) { for (int i = 0; i < courses.size(); i++) { selectedIndicesList.add(i); } } else { for (int i = 0; i < courses.size(); i++) { if (activeCourses.contains(courses.get(i))) { selectedIndicesList.add(i); } } } Integer[] selectedIndicesArray = new Integer[selectedIndicesList.size()]; selectedIndicesList.toArray(selectedIndicesArray); chooseCoursesDialog = new MaterialDialog.Builder(this).title(R.string.choose_courses).items(items) .itemsCallbackMultiChoice(selectedIndicesArray, new MaterialDialog.ListCallbackMultiChoice() { @Override public boolean onSelection(MaterialDialog materialDialog, Integer[] integers, CharSequence[] charSequences) { return true; } }).positiveText(android.R.string.ok).neutralText(R.string.select_all) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { Integer[] selectedIndices = dialog.getSelectedIndices(); Set<String> newActiveCourses = new HashSet<String>(); for (Integer index : selectedIndices) { newActiveCourses.add(Long.toString(courses.get(index))); } IliasPropertiesUtil.setActiveCourses(IliasActivity.this, newActiveCourses); boolean syncAll = (selectedIndices.length == items.length); IliasPropertiesUtil.setSyncAll(IliasActivity.this, syncAll); } @Override public void onNeutral(MaterialDialog dialog) { Set<String> newActiveCourses = new HashSet<String>(); for (int i = 0; i < courses.size(); i++) { newActiveCourses.add(Long.toString(courses.get(i))); } IliasPropertiesUtil.setActiveCourses(IliasActivity.this, newActiveCourses); IliasPropertiesUtil.setSyncAll(IliasActivity.this, true); } }).build(); chooseCoursesDialog.show(); }
From source file:com.xxxifan.devbox.core.base.BaseFragment.java
private void restoreFragmentState(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.getBoolean(Fragments.KEY_RESTORE_VIEWPAGER, false)) { return; }/*from w w w . ja v a 2 s . co m*/ FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (savedInstanceState.getBoolean(Fragments.KEY_RESTORE, false)) { transaction.show(this); } else { transaction.hide(this); } transaction.commitAllowingStateLoss(); } }
From source file:ch.citux.td.ui.TDActivity.java
private void replaceFragment(Fragment fragment, boolean backstack) { if (fragment != null && !fragment.isAdded()) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content, fragment); if (backstack) { transaction.addToBackStack(null); }/*from ww w . j a v a 2 s.co m*/ transaction.commitAllowingStateLoss(); } }
From source file:com.jadebyte.popularmovies.activities.MainActivity.java
public void launchDetailsFrag(@NonNull Movie movie) { MovieDetailsFragment detailsFragment = new MovieDetailsFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(Constants.Keys.MOVIE_OBJECT, movie); detailsFragment.setArguments(bundle); int container = hasTwoPanes ? R.id.movie_content_details : R.id.movie_content_frame; FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.addToBackStack(null);/* w w w .ja v a2 s . c om*/ ft.add(container, detailsFragment, "MovieDetailsFragment"); ft.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commitAllowingStateLoss(); }
From source file:com.shenzhen.elson.selectordialoglib.SelectorDialog.java
public void dismiss() { if (mDismissed) { return;/*from w w w . j a v a 2s. c o m*/ } mDismissed = true; new Handler().post(new Runnable() { public void run() { getFragmentManager().popBackStack(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.remove(SelectorDialog.this); ft.commitAllowingStateLoss(); } }); }
From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java
public void show(FragmentManager manager, String tag) { if (!mDismissed || manager.isDestroyed()) { return;/*from w w w . j a v a 2 s . c o m*/ } mDismissed = false; FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.addToBackStack(null); ft.commitAllowingStateLoss(); }
From source file:org.mythdroid.activities.MDFragmentActivity.java
/** * Reset fragments - //w ww . j a v a 2s .c om * Called when configuration (orientation) changes - * Default implementation replaces the fragment occupying the 'content' id * with a new instance of the same class */ protected void resetContentView() { FragmentManager fm = getSupportFragmentManager(); Fragment f = null; try { f = fm.findFragmentById(android.R.id.content); } catch (Exception e) { ErrUtil.reportErr(this, e); return; } if (f == null) { ErrUtil.reportErr(this, Messages.getString("MDFragmentActivity.0")); //$NON-NLS-1$ return; } Bundle args = f.getArguments(); try { f = f.getClass().newInstance(); } catch (Exception e) { ErrUtil.reportErr(this, e); return; } f.setArguments(args); fm.popBackStackImmediate(); FragmentTransaction ft = fm.beginTransaction().replace(android.R.id.content, f, f.getClass().getSimpleName()); if (fm.getBackStackEntryCount() > 0) ft.addToBackStack(null); ft.commitAllowingStateLoss(); fm.executePendingTransactions(); }