mirror of https://github.com/M66B/FairEmail.git
Fixed Gravatar caching
This commit is contained in:
parent
3d2572cf7a
commit
45a6930068
|
@ -189,18 +189,19 @@ public class ContactInfo {
|
||||||
|
|
||||||
if (info.bitmap == null) {
|
if (info.bitmap == null) {
|
||||||
if (gravatars) {
|
if (gravatars) {
|
||||||
|
String gkey = address.getAddress().toLowerCase(Locale.ROOT);
|
||||||
boolean lookup;
|
boolean lookup;
|
||||||
synchronized (emailGravatar) {
|
synchronized (emailGravatar) {
|
||||||
Avatar avatar = emailGravatar.get(address.getAddress());
|
Avatar avatar = emailGravatar.get(gkey);
|
||||||
lookup = (avatar == null || avatar.isExpired() || avatar.isAvailable());
|
lookup = (avatar == null || avatar.isExpired() || avatar.isAvailable());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookup) {
|
if (lookup) {
|
||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection = null;
|
||||||
try {
|
try {
|
||||||
String hash = Helper.md5(address.getAddress().toLowerCase(Locale.ROOT).getBytes());
|
String hash = Helper.md5(gkey.getBytes());
|
||||||
URL url = new URL("https://www.gravatar.com/avatar/" + hash + "?d=404");
|
URL url = new URL("https://www.gravatar.com/avatar/" + hash + "?d=404");
|
||||||
Log.i("Gravatar url=" + url);
|
Log.i("Gravatar key=" + gkey + " url=" + url);
|
||||||
|
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
urlConnection = (HttpURLConnection) url.openConnection();
|
||||||
urlConnection.setRequestMethod("GET");
|
urlConnection.setRequestMethod("GET");
|
||||||
|
@ -214,12 +215,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(address.getAddress(), new Avatar(true));
|
emailGravatar.put(gkey, new Avatar(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(address.getAddress(), new Avatar(false));
|
emailGravatar.put(gkey, new Avatar(false));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
throw new IOException("HTTP status=" + status);
|
throw new IOException("HTTP status=" + status);
|
||||||
|
|
Loading…
Reference in New Issue