aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2020-01-31 07:09:03 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2020-01-31 07:09:03 +0100
commit6bb9db368638dbd129ac49db15c8308deaf1a5a7 (patch)
treec6ecd8dfe6a7855025c2848cfeb9a6ff06466eba
parentf5721e6c9649282ffabf501612a9991b7229a74b (diff)
evict cached previews when file gets deleted
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java9
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java1
2 files changed, 10 insertions, 0 deletions
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();