Skip to content

Commit

Permalink
[MaterialToolbar] Add null check for logo ConstantState check
Browse files Browse the repository at this point in the history
Resolves #2708

PiperOrigin-RevId: 449305810
(cherry picked from commit 2ac796f)
  • Loading branch information
dsn5ft authored and pekingme committed May 25, 2022
1 parent 0356d7c commit 299c8e1
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -90,12 +90,17 @@ public static ImageView getLogoImageView(@NonNull Toolbar toolbar) {

@Nullable
private static ImageView getImageView(@NonNull Toolbar toolbar, @Nullable Drawable content) {
if (content == null) {
return null;
}
for (int i = 0; i < toolbar.getChildCount(); i++) {
View child = toolbar.getChildAt(i);
if (child instanceof ImageView) {
ImageView imageView = (ImageView) child;
if (content != null
&& imageView.getDrawable().getConstantState().equals(content.getConstantState())) {
Drawable drawable = imageView.getDrawable();
if (drawable != null
&& drawable.getConstantState() != null
&& drawable.getConstantState().equals(content.getConstantState())) {
return imageView;
}
}
Expand Down

0 comments on commit 299c8e1

Please sign in to comment.