Skip to content

Commit 299c8e1

Browse files
dsn5ftpekingme
authored andcommitted
[MaterialToolbar] Add null check for logo ConstantState check
Resolves #2708 PiperOrigin-RevId: 449305810 (cherry picked from commit 2ac796f)
1 parent 0356d7c commit 299c8e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/java/com/google/android/material/internal/ToolbarUtils.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ public static ImageView getLogoImageView(@NonNull Toolbar toolbar) {
9090

9191
@Nullable
9292
private static ImageView getImageView(@NonNull Toolbar toolbar, @Nullable Drawable content) {
93+
if (content == null) {
94+
return null;
95+
}
9396
for (int i = 0; i < toolbar.getChildCount(); i++) {
9497
View child = toolbar.getChildAt(i);
9598
if (child instanceof ImageView) {
9699
ImageView imageView = (ImageView) child;
97-
if (content != null
98-
&& imageView.getDrawable().getConstantState().equals(content.getConstantState())) {
100+
Drawable drawable = imageView.getDrawable();
101+
if (drawable != null
102+
&& drawable.getConstantState() != null
103+
&& drawable.getConstantState().equals(content.getConstantState())) {
99104
return imageView;
100105
}
101106
}

0 commit comments

Comments
 (0)