Skip fetching favicons for junk

pull/183/head
M66B 5 years ago
parent eb9077b631
commit 36bdb9766a

@ -1127,7 +1127,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
all.addAll(Arrays.asList(senders));
if (show_recipients && recipients != null)
all.addAll(Arrays.asList(recipients));
ContactInfo[] info = ContactInfo.getCached(context, message.account, all.toArray(new Address[0]));
ContactInfo[] info = ContactInfo.getCached(context, message.account, message.folderType, all.toArray(new Address[0]));
if (info == null) {
if (taskContactInfo != null)
taskContactInfo.cancel(context);
@ -1135,6 +1135,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle aargs = new Bundle();
aargs.putLong("id", message.id);
aargs.putLong("account", message.account);
aargs.putString("folderType", message.folderType);
aargs.putSerializable("senders", senders);
aargs.putSerializable("recipients", show_recipients ? recipients : null);
@ -1142,6 +1143,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected ContactInfo[] onExecute(Context context, Bundle args) {
long account = args.getLong("account");
String folderType = args.getString("folderType");
Address[] senders = (Address[]) args.getSerializable("senders");
Address[] recipients = (Address[]) args.getSerializable("recipients");
@ -1154,7 +1156,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
System.arraycopy(senders, 0, all, 0, senders.length);
System.arraycopy(recipients, 0, all, senders.length, recipients.length);
return ContactInfo.get(context, account, all);
return ContactInfo.get(context, account, folderType, all);
}
@Override

@ -160,21 +160,21 @@ public class ContactInfo {
}
@NonNull
static ContactInfo[] get(Context context, long account, Address[] addresses) {
return get(context, account, addresses, false);
static ContactInfo[] get(Context context, long account, String folderType, Address[] addresses) {
return get(context, account, folderType, addresses, false);
}
static ContactInfo[] getCached(Context context, long account, Address[] addresses) {
return get(context, account, addresses, true);
static ContactInfo[] getCached(Context context, long account, String folderType, Address[] addresses) {
return get(context, account, folderType, addresses, true);
}
private static ContactInfo[] get(Context context, long account, Address[] addresses, boolean cacheOnly) {
private static ContactInfo[] get(Context context, long account, String folderType, Address[] addresses, boolean cacheOnly) {
if (addresses == null || addresses.length == 0)
return new ContactInfo[]{new ContactInfo()};
ContactInfo[] result = new ContactInfo[addresses.length];
for (int i = 0; i < addresses.length; i++) {
result[i] = _get(context, account, (InternetAddress) addresses[i], cacheOnly);
result[i] = _get(context, account, folderType, (InternetAddress) addresses[i], cacheOnly);
if (result[i] == null)
return null;
}
@ -182,7 +182,7 @@ public class ContactInfo {
return result;
}
private static ContactInfo _get(Context context, long account, InternetAddress address, boolean cacheOnly) {
private static ContactInfo _get(Context context, long account, String folderType, InternetAddress address, boolean cacheOnly) {
String key = MessageHelper.formatAddresses(new Address[]{address});
synchronized (emailContactInfo) {
ContactInfo info = emailContactInfo.get(key);
@ -295,7 +295,8 @@ public class ContactInfo {
}
// Favicon
if (info.bitmap == null && favicons) {
if (info.bitmap == null && favicons &&
!EntityFolder.JUNK.equals(folderType)) {
int at = (info.email == null ? -1 : info.email.indexOf('@'));
String domain = (at < 0 ? null : info.email.substring(at + 1).toLowerCase(Locale.ROOT));

@ -3282,7 +3282,7 @@ class Core {
Map<Long, Address[]> messageFrom = new HashMap<>();
Map<Long, ContactInfo[]> messageInfo = new HashMap<>();
for (TupleMessageEx message : messages) {
ContactInfo[] info = ContactInfo.get(context, message.account, message.from);
ContactInfo[] info = ContactInfo.get(context, message.account, message.folderType, message.from);
Address[] modified = (message.from == null
? new InternetAddress[0]

Loading…
Cancel
Save