Fix identicon crash

This commit is contained in:
Niels Andriesse 2019-08-19 09:21:18 +10:00
parent 21fc47d7bf
commit 342bd797b8
2 changed files with 8 additions and 2 deletions

View File

@ -199,8 +199,11 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
@Override @Override
public boolean onPreDraw() { public boolean onPreDraw() {
int width = profilePictureImageView.getWidth();
int height = profilePictureImageView.getHeight();
if (width == 0 || height == 0) return true;
profilePictureImageView.getViewTreeObserver().removeOnPreDrawListener(this); profilePictureImageView.getViewTreeObserver().removeOnPreDrawListener(this);
ClassicIdenticonDrawable identicon = new ClassicIdenticonDrawable(profilePictureImageView.getWidth(), profilePictureImageView.getHeight(), recipient.getAddress().serialize().hashCode()); ClassicIdenticonDrawable identicon = new ClassicIdenticonDrawable(width, height, recipient.getAddress().serialize().hashCode());
profilePictureImageView.setImageDrawable(identicon); profilePictureImageView.setImageDrawable(identicon);
return true; return true;
} }

View File

@ -97,8 +97,11 @@ public class ProfilePreference extends Preference {
@Override @Override
public boolean onPreDraw() { public boolean onPreDraw() {
int width = avatarView.getWidth();
int height = avatarView.getHeight();
if (width == 0 || height == 0) return true;
avatarView.getViewTreeObserver().removeOnPreDrawListener(this); avatarView.getViewTreeObserver().removeOnPreDrawListener(this);
ClassicIdenticonDrawable identicon = new ClassicIdenticonDrawable(avatarView.getWidth(), avatarView.getHeight(), userHexEncodedPublicKey.hashCode()); ClassicIdenticonDrawable identicon = new ClassicIdenticonDrawable(width, height, userHexEncodedPublicKey.hashCode());
avatarView.setImageDrawable(identicon); avatarView.setImageDrawable(identicon);
return true; return true;
} }