diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 3eaa9e406..33a524894 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -589,12 +589,17 @@ public class FileBackend { } public Bitmap getThumbnail(Message message, int size, boolean cacheOnly) throws IOException { - final String uuid = message.getUuid(); + // The key for getting a cached thumbnail contains the UUID and the size + // since this method is used for thumbnails of (bigger) normal image messages and (smaller) image message references. + // If only the UUID were used, the first loaded thumbnail would be cached and the next loading + // would get that thumbnail which would have the size of the first cached thumbnail + // possibly leading to undesirable appearance of the displayed thumbnail. + final String key = message.getUuid() + String.valueOf(size);final String uuid = message.getUuid(); final LruCache<String, Bitmap> cache = mXmppConnectionService.getBitmapCache(); - Bitmap thumbnail = cache.get(uuid); + Bitmap thumbnail = cache.get(key ); if ((thumbnail == null) && (!cacheOnly)) { synchronized (THUMBNAIL_LOCK) { - thumbnail = cache.get(uuid); + thumbnail = cache.get(key ); if (thumbnail != null) { return thumbnail; } @@ -616,7 +621,7 @@ public class FileBackend { thumbnail = withGifOverlay; } } - cache.put(uuid, thumbnail); + cache.put(key , thumbnail); } } return thumbnail; |