Refactoring

pull/199/head
M66B 3 years ago
parent 421a86098f
commit d3da6d42fe

@ -96,7 +96,7 @@ public class ContactInfo {
private static Map<String, Lookup> emailLookup = new ConcurrentHashMap<>(); private static Map<String, Lookup> emailLookup = new ConcurrentHashMap<>();
private static final Map<String, ContactInfo> emailContactInfo = new HashMap<>(); private static final Map<String, ContactInfo> emailContactInfo = new HashMap<>();
private static final Map<String, Avatar> emailGravatar = new HashMap<>(); private static final Map<String, Gravatar> emailGravatar = new HashMap<>();
private static final ExecutorService executorLookup = private static final ExecutorService executorLookup =
Helper.getBackgroundExecutor(1, "contact"); Helper.getBackgroundExecutor(1, "contact");
@ -304,7 +304,7 @@ public class ContactInfo {
String gkey = info.email.toLowerCase(Locale.ROOT); String gkey = info.email.toLowerCase(Locale.ROOT);
boolean lookup; boolean lookup;
synchronized (emailGravatar) { synchronized (emailGravatar) {
Avatar avatar = emailGravatar.get(gkey); Gravatar avatar = emailGravatar.get(gkey);
lookup = (avatar == null || avatar.isExpired() || avatar.isAvailable()); lookup = (avatar == null || avatar.isExpired() || avatar.isAvailable());
} }
@ -328,12 +328,12 @@ public class ContactInfo {
info.bitmap = BitmapFactory.decodeStream(urlConnection.getInputStream()); info.bitmap = BitmapFactory.decodeStream(urlConnection.getInputStream());
// Positive reply // Positive reply
synchronized (emailGravatar) { synchronized (emailGravatar) {
emailGravatar.put(gkey, new Avatar(true)); emailGravatar.put(gkey, new Gravatar(true));
} }
} else if (status == HttpURLConnection.HTTP_NOT_FOUND) { } else if (status == HttpURLConnection.HTTP_NOT_FOUND) {
// Negative reply // Negative reply
synchronized (emailGravatar) { synchronized (emailGravatar) {
emailGravatar.put(gkey, new Avatar(false)); emailGravatar.put(gkey, new Gravatar(false));
} }
} else } else
throw new IOException("HTTP status=" + status); throw new IOException("HTTP status=" + status);
@ -1089,11 +1089,11 @@ public class ContactInfo {
} }
} }
private static class Avatar { private static class Gravatar {
private boolean available; private boolean available;
private long time; private long time;
Avatar(boolean available) { Gravatar(boolean available) {
this.available = available; this.available = available;
this.time = new Date().getTime(); this.time = new Date().getTime();
} }

Loading…
Cancel
Save