Fixed empty avatar when disabled

This commit is contained in:
M66B 2020-05-06 15:07:45 +02:00
parent 124a86aac8
commit 5fb6e47741
1 changed files with 25 additions and 21 deletions

View File

@ -845,12 +845,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvFolder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvFolder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
int px = Math.round(fz_sender + fz_subject + (compact ? 0 : textSize * 0.9f)); if (avatars) {
ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams(); int px = Math.round(fz_sender + fz_subject + (compact ? 0 : textSize * 0.9f));
if (lparams.height != px) { ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams();
lparams.width = px; if (lparams.height != px) {
lparams.height = px; lparams.width = px;
ibAvatar.requestLayout(); lparams.height = px;
ibAvatar.requestLayout();
}
} }
} }
@ -1297,24 +1299,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
for (ContactInfo c : info) for (ContactInfo c : info)
map.put(c.getEmailAddress(), c); map.put(c.getEmailAddress(), c);
ContactInfo main = null; if (avatars) {
if (senders != null && senders.length > 0) { ContactInfo main = null;
String email = ((InternetAddress) senders[0]).getAddress(); if (senders != null && senders.length > 0) {
if (!TextUtils.isEmpty(email)) String email = ((InternetAddress) senders[0]).getAddress();
main = map.get(email); if (!TextUtils.isEmpty(email))
} main = map.get(email);
}
if (main == null) { if (main == null) {
ibAvatar.setImageDrawable(null); ibAvatar.setImageDrawable(null);
ibAvatar.setTag(null); ibAvatar.setTag(null);
} else { } else {
ibAvatar.setImageBitmap(main.getPhotoBitmap()); ibAvatar.setImageBitmap(main.getPhotoBitmap());
Uri lookupUri = main.getLookupUri(); Uri lookupUri = main.getLookupUri();
ibAvatar.setTag(lookupUri); ibAvatar.setTag(lookupUri);
ibAvatar.setEnabled(lookupUri != null); ibAvatar.setEnabled(lookupUri != null);
}
ibAvatar.setVisibility(main == null ? View.GONE : View.VISIBLE);
} }
ibAvatar.setVisibility(main == null ? View.GONE : View.VISIBLE);
Address[] _senders = fillIn(senders, map); Address[] _senders = fillIn(senders, map);
Address[] _recipients = fillIn(recipients, map); Address[] _recipients = fillIn(recipients, map);