From 56ed07008ba0bff682e99c5d91126596fe9e6ddf Mon Sep 17 00:00:00 2001 From: dsn5ft <1420597+dsn5ft@users.noreply.github.com> Date: Fri, 11 Feb 2022 10:20:22 -0800 Subject: [PATCH] [Color] Update DynamicColors to use peekDecorView() instead of getDecorView() when applying dynamic color theme overlay Resolves https://github.com/material-components/material-components-android/issues/2558 PiperOrigin-RevId: 428033173 --- lib/java/com/google/android/material/color/DynamicColors.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/java/com/google/android/material/color/DynamicColors.java b/lib/java/com/google/android/material/color/DynamicColors.java index d4767a975b2..e271566f8d9 100644 --- a/lib/java/com/google/android/material/color/DynamicColors.java +++ b/lib/java/com/google/android/material/color/DynamicColors.java @@ -315,7 +315,8 @@ private static void applyDynamicColorThemeOverlay(Activity activity, @StyleRes i private static Theme getWindowDecorViewTheme(@NonNull Activity activity) { Window window = activity.getWindow(); if (window != null) { - View decorView = window.getDecorView(); + // Use peekDecorView() instead of getDecorView() to avoid locking the Window. + View decorView = window.peekDecorView(); if (decorView != null) { Context context = decorView.getContext(); if (context != null) {