diff options
author | George Mount <mount@google.com> | 2014-09-17 16:36:42 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2014-09-18 15:24:48 -0700 |
commit | 0b26e4d58ab1a60340dd7ab35ca6e3bddff9f760 (patch) | |
tree | 06c65e80b1335b074d997696e28261adc211c555 /core | |
parent | 5083943ff85c7452b166e6c2b044e3d9dae9d017 (diff) | |
download | frameworks_base-0b26e4d58ab1a60340dd7ab35ca6e3bddff9f760.zip frameworks_base-0b26e4d58ab1a60340dd7ab35ca6e3bddff9f760.tar.gz frameworks_base-0b26e4d58ab1a60340dd7ab35ca6e3bddff9f760.tar.bz2 |
Fix exception when fragment container has no View.
Bug 17535259
Change-Id: I29c9ef53dd693cbb4043ebfb4750753870c9e99a
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/Activity.java | 5 | ||||
-rw-r--r-- | core/java/android/app/BackStackRecord.java | 6 | ||||
-rw-r--r-- | core/java/android/app/Fragment.java | 5 | ||||
-rw-r--r-- | core/java/android/app/FragmentManager.java | 1 |
4 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 701ab1d..9e53a35 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -745,6 +745,11 @@ public class Activity extends ContextThemeWrapper public View findViewById(int id) { return Activity.this.findViewById(id); } + @Override + public boolean hasView() { + Window window = Activity.this.getWindow(); + return (window != null && window.peekDecorView() != null); + } }; // Most recent call to requestVisibleBehind(). diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java index 832e1e3..8644c3d 100644 --- a/core/java/android/app/BackStackRecord.java +++ b/core/java/android/app/BackStackRecord.java @@ -868,6 +868,9 @@ final class BackStackRecord extends FragmentTransaction implements */ private void calculateFragments(SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments) { + if (!mManager.mContainer.hasView()) { + return; // nothing to see, so no transitions + } Op op = mHead; while (op != null) { switch (op.cmd) { @@ -923,6 +926,9 @@ final class BackStackRecord extends FragmentTransaction implements */ public void calculateBackFragments(SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments) { + if (!mManager.mContainer.hasView()) { + return; // nothing to see, so no transitions + } Op op = mHead; while (op != null) { switch (op.cmd) { diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index a95abab..5196834 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -2015,6 +2015,11 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene } return mView.findViewById(id); } + + @Override + public boolean hasView() { + return (mView != null); + } }, this); } diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index ef69fdd..fc761fe 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -395,6 +395,7 @@ final class FragmentManagerState implements Parcelable { */ interface FragmentContainer { public View findViewById(int id); + public boolean hasView(); } /** |