Refactoring

This commit is contained in:
M66B 2021-07-14 07:25:46 +02:00
parent 421a86098f
commit d3da6d42fe
1 changed files with 6 additions and 6 deletions

View File

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