Stop double caching the thumbnails

Notification doesn't need it cached anyway, so save the space.
This commit is contained in:
Stephen Paul Weber 2022-03-09 11:19:26 -05:00
parent 840c96c5e1
commit 7a809bd26a
No known key found for this signature in database
GPG key ID: D11C2911CE519CDE
2 changed files with 5 additions and 13 deletions

View file

@ -946,18 +946,10 @@ public class FileBackend {
return thumbnail; return thumbnail;
} }
public Bitmap getThumbnailBitmap(Message message, Resources res, int size, boolean cacheOnly) throws IOException { public Bitmap getThumbnailBitmap(Message message, Resources res, int size) throws IOException {
final String uuid = message.getUuid(); final Drawable drawable = getThumbnail(message, res, size, false);
final LruCache<String, Bitmap> cache = mXmppConnectionService.getBitmapCache(); if (drawable == null) return null;
Bitmap thumbnail = cache.get(uuid); return drawDrawable(drawable);
if ((thumbnail == null) && (!cacheOnly)) {
final Drawable drawable = getThumbnail(message, res, size, cacheOnly);
if (drawable != null) {
thumbnail = drawDrawable(drawable);
cache.put(uuid, thumbnail);
}
}
return thumbnail;
} }
private Drawable getImagePreview(File file, Resources res, int size, final String mime) throws IOException { private Drawable getImagePreview(File file, Resources res, int size, final String mime) throws IOException {

View file

@ -1062,7 +1062,7 @@ public class NotificationService {
private void modifyForImage(final Builder builder, final Message message, final ArrayList<Message> messages) { private void modifyForImage(final Builder builder, final Message message, final ArrayList<Message> messages) {
try { try {
final Bitmap bitmap = mXmppConnectionService.getFileBackend().getThumbnailBitmap(message, mXmppConnectionService.getResources(), getPixel(288), false); final Bitmap bitmap = mXmppConnectionService.getFileBackend().getThumbnailBitmap(message, mXmppConnectionService.getResources(), getPixel(288));
final ArrayList<Message> tmp = new ArrayList<>(); final ArrayList<Message> tmp = new ArrayList<>();
for (final Message msg : messages) { for (final Message msg : messages) {
if (msg.getType() == Message.TYPE_TEXT if (msg.getType() == Message.TYPE_TEXT