diff options
| author | 2017-01-17 17:01:37 -0800 | |
|---|---|---|
| committer | 2017-01-17 17:09:28 -0800 | |
| commit | 498348d34b6267b27d4cb1b5e4fd99b6e60c07d0 (patch) | |
| tree | 58b3057df1ae60dcb020d431c3af9c457d67cf4d | |
| parent | 5feafb1f71a314e7c40152dd4d369fcc0c166628 (diff) | |
Protect use of onFindViewById for Fragment Transitions.
Bug 34163850
onFindViewById is only valid once the Fragment's View
has been created, but the child fragment manager
can be used prior to its creation. This protects
the use of onFindViewById from use by fragment
transitions.
Test: Ic72cd7dae8d7982b78258116e7910c4f07d75d50
Change-Id: I67e3b2d5f59c2e741f29211d08ab07476c78a0ca
| -rw-r--r-- | core/java/android/app/FragmentTransition.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/app/FragmentTransition.java b/core/java/android/app/FragmentTransition.java index 6d57cd438a6f..80a5aacbd9dd 100644 --- a/core/java/android/app/FragmentTransition.java +++ b/core/java/android/app/FragmentTransition.java @@ -188,7 +188,10 @@ class FragmentTransition { private static void configureTransitionsOptimized(FragmentManagerImpl fragmentManager, int containerId, FragmentContainerTransition fragments, View nonExistentView, ArrayMap<String, String> nameOverrides) { - ViewGroup sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId); + ViewGroup sceneRoot = null; + if (fragmentManager.mContainer.onHasView()) { + sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId); + } if (sceneRoot == null) { return; } @@ -257,7 +260,10 @@ class FragmentTransition { private static void configureTransitionsUnoptimized(FragmentManagerImpl fragmentManager, int containerId, FragmentContainerTransition fragments, View nonExistentView, ArrayMap<String, String> nameOverrides) { - ViewGroup sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId); + ViewGroup sceneRoot = null; + if (fragmentManager.mContainer.onHasView()) { + sceneRoot = (ViewGroup) fragmentManager.mContainer.onFindViewById(containerId); + } if (sceneRoot == null) { return; } |