diff options
| author | Dianne Hackborn <hackbod@google.com> | 2011-03-11 13:17:57 -0800 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2011-03-11 13:48:32 -0800 |
| commit | cf407ad88bef3bc640489b300f23eaa8ea0b724e (patch) | |
| tree | e4690beb12fc2a68a7466a08a0a302fa41b2fdb3 /core/java/android/app/DialogFragment.java | |
| parent | 0eb7b697b7c180660647b5cd0cd7dd067f6b6abb (diff) | |
Fix issues #4087362 and #4087356
4087362: Provide a safer way to call DialogFragment.dismiss()
4087356: PreferenceActivity.invalidateHeaders() can cause
IllegalStateException: Can not perform this action after onSaveInstanceState
These are very safe; the first is just a new public API that
allows you to use an existing feature in DialogFragment, and the
second just uses the version of commit that avoids the failure if
happening at a point where the operation would be lost if restored
from the last state (which is no big deal for preferences).
Change-Id: I53971c9fb1efdcd599694cdcd4585b81afc156b8
Diffstat (limited to 'core/java/android/app/DialogFragment.java')
| -rw-r--r-- | core/java/android/app/DialogFragment.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java index dee1ef3a0a27..cce7cd6bd8fe 100644 --- a/core/java/android/app/DialogFragment.java +++ b/core/java/android/app/DialogFragment.java @@ -258,6 +258,16 @@ public class DialogFragment extends Fragment dismissInternal(false); } + /** + * Version of {@link #dismiss()} that uses + * {@link FragmentTransaction#commitAllowingStateLoss() + * FragmentTransaction.commitAllowingStateLoss()}. See linked + * documentation for further details. + */ + public void dismissAllowingStateLoss() { + dismissInternal(true); + } + void dismissInternal(boolean allowStateLoss) { if (mDismissed) { return; |
