Refactor AvatarImageView#setAvatarClickHandler.
This triggered a call to Recipient#isGroup when rendering a view, which itself could trigger a DB read. This delays the call to #isGroup to lower the possibility of doing DB reads on the main thread.
This commit is contained in:
parent
d7c350f987
commit
848101a783
1 changed files with 6 additions and 6 deletions
|
@ -136,17 +136,17 @@ public final class AvatarImageView extends AppCompatImageView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAvatarClickHandler(final Recipient recipient, boolean quickContactEnabled) {
|
private void setAvatarClickHandler(final Recipient recipient, boolean quickContactEnabled) {
|
||||||
if (!recipient.isGroup() && quickContactEnabled) {
|
super.setOnClickListener(v -> {
|
||||||
super.setOnClickListener(v -> {
|
if (!recipient.isGroup() && quickContactEnabled) {
|
||||||
if (recipient.getContactUri() != null) {
|
if (recipient.getContactUri() != null) {
|
||||||
ContactsContract.QuickContact.showQuickContact(getContext(), AvatarImageView.this, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
ContactsContract.QuickContact.showQuickContact(getContext(), AvatarImageView.this, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
||||||
} else {
|
} else {
|
||||||
getContext().startActivity(RecipientExporter.export(recipient).asAddContactIntent());
|
getContext().startActivity(RecipientExporter.export(recipient).asAddContactIntent());
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
} else {
|
listener.onClick(v);
|
||||||
super.setOnClickListener(listener);
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RecipientContactPhoto {
|
private static class RecipientContactPhoto {
|
||||||
|
|
Loading…
Add table
Reference in a new issue