Merge "Fix NPE in DialogLaunchAnimator" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-12-02 10:58:56 +00:00
committed by Android (Google) Code Review
3 changed files with 9 additions and 7 deletions

View File

@@ -75,7 +75,7 @@ constructor(
*/ */
interface Controller { interface Controller {
/** The [ViewRootImpl] of this controller. */ /** The [ViewRootImpl] of this controller. */
val viewRoot: ViewRootImpl val viewRoot: ViewRootImpl?
/** /**
* The identity object of the source animated by this controller. This animator will ensure * The identity object of the source animated by this controller. This animator will ensure
@@ -807,15 +807,17 @@ private class AnimatedDialog(
* inversely, removed from the overlay when the source is moved back to its original position). * inversely, removed from the overlay when the source is moved back to its original position).
*/ */
private fun synchronizeNextDraw(then: () -> Unit) { private fun synchronizeNextDraw(then: () -> Unit) {
if (forceDisableSynchronization) { val controllerRootView = controller.viewRoot?.view
// Don't synchronize when inside an automated test. if (forceDisableSynchronization || controllerRootView == null) {
// Don't synchronize when inside an automated test or if the controller root view is
// detached.
then() then()
return return
} }
ViewRootSync.synchronizeNextDraw(controller.viewRoot.view, decorView, then) ViewRootSync.synchronizeNextDraw(controllerRootView, decorView, then)
decorView.invalidate() decorView.invalidate()
controller.viewRoot.view.invalidate() controllerRootView.invalidate()
} }
private fun findFirstViewGroupWithBackground(view: View): ViewGroup? { private fun findFirstViewGroupWithBackground(view: View): ViewGroup? {

View File

@@ -28,7 +28,7 @@ internal constructor(
private val source: View, private val source: View,
override val cuj: DialogCuj?, override val cuj: DialogCuj?,
) : DialogLaunchAnimator.Controller { ) : DialogLaunchAnimator.Controller {
override val viewRoot: ViewRootImpl override val viewRoot: ViewRootImpl?
get() = source.viewRootImpl get() = source.viewRootImpl
override val sourceIdentity: Any = source override val sourceIdentity: Any = source

View File

@@ -262,7 +262,7 @@ internal class ExpandableControllerImpl(
private fun dialogController(cuj: DialogCuj?): DialogLaunchAnimator.Controller { private fun dialogController(cuj: DialogCuj?): DialogLaunchAnimator.Controller {
return object : DialogLaunchAnimator.Controller { return object : DialogLaunchAnimator.Controller {
override val viewRoot: ViewRootImpl = composeViewRoot.viewRootImpl override val viewRoot: ViewRootImpl? = composeViewRoot.viewRootImpl
override val sourceIdentity: Any = this@ExpandableControllerImpl override val sourceIdentity: Any = this@ExpandableControllerImpl
override val cuj: DialogCuj? = cuj override val cuj: DialogCuj? = cuj