Fixed contact info caching

pull/147/head
M66B 7 years ago
parent 811fbfc9b4
commit 3b5c5f9dad

@ -76,9 +76,9 @@ public class ContactInfo {
return new ContactInfo(); return new ContactInfo();
InternetAddress address = (InternetAddress) addresses[0]; InternetAddress address = (InternetAddress) addresses[0];
String email = address.getAddress(); String key = address.toString();
synchronized (emailContactInfo) { synchronized (emailContactInfo) {
ContactInfo info = emailContactInfo.get(email); ContactInfo info = emailContactInfo.get(key);
if (info != null && !info.isExpired()) if (info != null && !info.isExpired())
return info; return info;
} }
@ -87,7 +87,7 @@ public class ContactInfo {
return null; return null;
ContactInfo info = new ContactInfo(); ContactInfo info = new ContactInfo();
info.email = email; info.email = address.getAddress();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -105,7 +105,7 @@ public class ContactInfo {
}, },
ContactsContract.CommonDataKinds.Email.ADDRESS + " = ?", ContactsContract.CommonDataKinds.Email.ADDRESS + " = ?",
new String[]{ new String[]{
email address.getAddress()
}, null); }, null);
if (cursor != null && cursor.moveToNext()) { if (cursor != null && cursor.moveToNext()) {
@ -139,7 +139,7 @@ public class ContactInfo {
if (identicons) { if (identicons) {
String theme = prefs.getString("theme", "light"); String theme = prefs.getString("theme", "light");
int dp = Helper.dp2pixels(context, 48); int dp = Helper.dp2pixels(context, 48);
info.bitmap = Identicon.generate(email, dp, 5, "light".equals(theme)); info.bitmap = Identicon.generate(key, dp, 5, "light".equals(theme));
} }
} }
@ -147,7 +147,7 @@ public class ContactInfo {
info.displayName = address.getPersonal(); info.displayName = address.getPersonal();
synchronized (emailContactInfo) { synchronized (emailContactInfo) {
emailContactInfo.put(email, info); emailContactInfo.put(key, info);
} }
info.time = new Date().getTime(); info.time = new Date().getTime();

Loading…
Cancel
Save