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) {
|
||||
if (!recipient.isGroup() && quickContactEnabled) {
|
||||
super.setOnClickListener(v -> {
|
||||
super.setOnClickListener(v -> {
|
||||
if (!recipient.isGroup() && quickContactEnabled) {
|
||||
if (recipient.getContactUri() != null) {
|
||||
ContactsContract.QuickContact.showQuickContact(getContext(), AvatarImageView.this, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null);
|
||||
} else {
|
||||
getContext().startActivity(RecipientExporter.export(recipient).asAddContactIntent());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
super.setOnClickListener(listener);
|
||||
}
|
||||
} else {
|
||||
listener.onClick(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class RecipientContactPhoto {
|
||||
|
|
Loading…
Add table
Reference in a new issue