Merge "Expose isStateSaved() in FragmentManager."
This commit is contained in:
committed by
Android (Google) Code Review
commit
189796dace
@@ -4737,6 +4737,7 @@ package android.app {
|
||||
method public abstract android.app.Fragment getPrimaryNavigationFragment();
|
||||
method public void invalidateOptionsMenu();
|
||||
method public abstract boolean isDestroyed();
|
||||
method public abstract boolean isStateSaved();
|
||||
method public abstract void popBackStack();
|
||||
method public abstract void popBackStack(java.lang.String, int);
|
||||
method public abstract void popBackStack(int, int);
|
||||
|
||||
@@ -4898,6 +4898,7 @@ package android.app {
|
||||
method public abstract android.app.Fragment getPrimaryNavigationFragment();
|
||||
method public void invalidateOptionsMenu();
|
||||
method public abstract boolean isDestroyed();
|
||||
method public abstract boolean isStateSaved();
|
||||
method public abstract void popBackStack();
|
||||
method public abstract void popBackStack(java.lang.String, int);
|
||||
method public abstract void popBackStack(int, int);
|
||||
|
||||
@@ -4747,6 +4747,7 @@ package android.app {
|
||||
method public abstract android.app.Fragment getPrimaryNavigationFragment();
|
||||
method public void invalidateOptionsMenu();
|
||||
method public abstract boolean isDestroyed();
|
||||
method public abstract boolean isStateSaved();
|
||||
method public abstract void popBackStack();
|
||||
method public abstract void popBackStack(java.lang.String, int);
|
||||
method public abstract void popBackStack(int, int);
|
||||
|
||||
@@ -2822,7 +2822,9 @@ public class Activity extends ContextThemeWrapper
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mFragments.getFragmentManager().popBackStackImmediate()) {
|
||||
FragmentManager fragmentManager = mFragments.getFragmentManager();
|
||||
|
||||
if (fragmentManager.isStateSaved() || !fragmentManager.popBackStackImmediate()) {
|
||||
finishAfterTransition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,6 +396,19 @@ public abstract class FragmentManager {
|
||||
*/
|
||||
public void invalidateOptionsMenu() { }
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the FragmentManager's state has already been saved
|
||||
* by its host. Any operations that would change saved state should not be performed
|
||||
* if this method returns true. For example, any popBackStack() method, such as
|
||||
* {@link #popBackStackImmediate()} or any FragmentTransaction using
|
||||
* {@link FragmentTransaction#commit()} instead of
|
||||
* {@link FragmentTransaction#commitAllowingStateLoss()} will change
|
||||
* the state and will result in an error.
|
||||
*
|
||||
* @return true if this FragmentManager's state has already been saved by its host
|
||||
*/
|
||||
public abstract boolean isStateSaved();
|
||||
|
||||
/**
|
||||
* Callback interface for listening to fragment state changes that happen
|
||||
* within a given FragmentManager.
|
||||
@@ -1787,6 +1800,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStateSaved() {
|
||||
return mStateSaved;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user