From 29f05b94ab802736cdc36e1041484a25f79f6602 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 9 Jun 2020 09:45:06 +0200 Subject: [PATCH] Fixed showing avatars when no email address --- .../eu/faircode/email/AdapterMessage.java | 42 ++++++------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index d76d56d2b0..a47abf8236 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1139,21 +1139,16 @@ public class AdapterMessage extends RecyclerView.Adapter map = new HashMap<>(); - if (senders != null) - for (Address a : senders) { - String email = ((InternetAddress) a).getAddress(); - 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); - } + if (senders == null) + senders = new Address[0]; + if (recipients == null) + recipients = new Address[0]; - 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 @@ -1336,18 +1331,8 @@ public class AdapterMessage extends RecyclerView.Adapter map = new HashMap<>(); - for (ContactInfo c : info) - map.put(c.getEmailAddress(), c); - if (avatars) { - ContactInfo main = null; - if (senders != null && senders.length > 0) { - String email = ((InternetAddress) senders[0]).getAddress(); - if (!TextUtils.isEmpty(email)) - main = map.get(email); - } - + ContactInfo main = (info.length > 0 ? info[0] : null); if (main == null || !main.hasPhoto()) { ibAvatar.setImageDrawable(null); ibAvatar.setTag(null); @@ -1364,14 +1349,11 @@ public class AdapterMessage extends RecyclerView.Adapter