aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance/FileBackend.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-05-09 21:47:50 +0200
committerChristian Schneppe <christian@pix-art.de>2019-05-18 00:01:57 +0200
commit294144943429503f62675d23b9911d43c0f41ce3 (patch)
tree6ca73458e72a8afe0a148f8971726eeb7311ea71 /src/main/java/de/pixart/messenger/persistance/FileBackend.java
parent5b75d52d444d6cda368e85f5884163e229451ece (diff)
performance improvements
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance/FileBackend.java')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java13
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;