Fixed showing avatars when no email address

pull/180/head
M66B 5 years ago
parent 3de7db665e
commit 29f05b94ab

@ -1139,21 +1139,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Address[] senders = (Address[]) args.getSerializable("senders"); Address[] senders = (Address[]) args.getSerializable("senders");
Address[] recipients = (Address[]) args.getSerializable("recipients"); Address[] recipients = (Address[]) args.getSerializable("recipients");
Map<String, Address> map = new HashMap<>(); if (senders == null)
if (senders != null) senders = new Address[0];
for (Address a : senders) { if (recipients == null)
String email = ((InternetAddress) a).getAddress(); recipients = new Address[0];
if (!TextUtils.isEmpty(email))
map.put(email, a);
}
if (recipients != null)
for (Address a : recipients) {
String email = ((InternetAddress) a).getAddress();
if (!TextUtils.isEmpty(email))
map.put(email, a);
}
return ContactInfo.get(context, account, map.values().toArray(new Address[0])); Address[] all = new Address[senders.length + recipients.length];
System.arraycopy(senders, 0, all, 0, senders.length);
System.arraycopy(recipients, 0, all, senders.length, recipients.length);
return ContactInfo.get(context, account, all);
} }
@Override @Override
@ -1336,18 +1331,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void bindContactInfo(TupleMessageEx message, ContactInfo[] info, Address[] senders, Address[] recipients) { private void bindContactInfo(TupleMessageEx message, ContactInfo[] info, Address[] senders, Address[] recipients) {
Map<String, ContactInfo> map = new HashMap<>();
for (ContactInfo c : info)
map.put(c.getEmailAddress(), c);
if (avatars) { if (avatars) {
ContactInfo main = null; ContactInfo main = (info.length > 0 ? info[0] : null);
if (senders != null && senders.length > 0) {
String email = ((InternetAddress) senders[0]).getAddress();
if (!TextUtils.isEmpty(email))
main = map.get(email);
}
if (main == null || !main.hasPhoto()) { if (main == null || !main.hasPhoto()) {
ibAvatar.setImageDrawable(null); ibAvatar.setImageDrawable(null);
ibAvatar.setTag(null); ibAvatar.setTag(null);
@ -1364,14 +1349,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (distinguish_contacts) { if (distinguish_contacts) {
boolean known = false; boolean known = false;
if (senders != null) if (senders != null)
for (Address sender : senders) { for (int i = 0; i < senders.length; i++)
String email = ((InternetAddress) sender).getAddress(); if (info[i].isKnown()) {
if (!TextUtils.isEmpty(email) &&
map.containsKey(email) && map.get(email).isKnown()) {
known = true; known = true;
break; break;
} }
}
if (known) if (known)
tvFrom.setPaintFlags(tvFrom.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); tvFrom.setPaintFlags(tvFrom.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
} }

Loading…
Cancel
Save