From 498348d34b6267b27d4cb1b5e4fd99b6e60c07d0 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 17 Jan 2017 17:01:37 -0800 Subject: [PATCH] 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 --- core/java/android/app/FragmentTransition.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/FragmentTransition.java b/core/java/android/app/FragmentTransition.java index 6d57cd438a6f2..80a5aacbd9dd2 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 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 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; }