From 6bb9db368638dbd129ac49db15c8308deaf1a5a7 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 31 Jan 2020 07:09:03 +0100 Subject: evict cached previews when file gets deleted --- .../java/de/pixart/messenger/services/XmppConnectionService.java | 9 +++++++++ src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 1 + 2 files changed, 10 insertions(+) diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index bd981774c..8f9c2ce98 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2109,6 +2109,9 @@ public class XmppConnectionService extends Service { for (Conversation conversation : getConversations()) { deleted |= conversation.markAsDeleted(uuids); } + for (final String uuid : uuids) { + evictPreview(uuid); + } if (deleted) { updateConversationUi(); } @@ -5052,6 +5055,12 @@ public class XmppConnectionService extends Service { sendIqPacket(account, set, null); } + public void evictPreview(String uuid) { + if (mBitmapCache.remove(uuid) != null) { + Log.d(Config.LOGTAG, "deleted cached preview"); + } + } + public interface OnMamPreferencesFetched { void onPreferencesFetched(Element prefs); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 997f67d29..a3edfb9fe 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1926,6 +1926,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke builder.setPositiveButton(R.string.confirm, (dialog, which) -> { if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { message.setFileDeleted(true); + activity.xmppConnectionService.evictPreview(message.getUuid()); activity.xmppConnectionService.updateMessage(message, false); activity.onConversationsListItemUpdated(); refresh(); -- cgit v1.2.3