evict cached previews when file gets deleted

This commit is contained in:
Daniel Gultsch 2020-01-20 10:54:55 +01:00
parent 66da5ffb6c
commit 843d7fe12d
3 changed files with 12 additions and 0 deletions

View File

@ -508,6 +508,8 @@ public class FileBackend {
return getFile(message, true); return getFile(message, true);
} }
public DownloadableFile getFileForPath(String path) { public DownloadableFile getFileForPath(String path) {
return getFileForPath(path, MimeUtils.guessMimeTypeFromExtension(MimeUtils.extractRelevantExtension(path))); return getFileForPath(path, MimeUtils.guessMimeTypeFromExtension(MimeUtils.extractRelevantExtension(path)));
} }

View File

@ -1854,6 +1854,9 @@ public class XmppConnectionService extends Service {
for (Conversation conversation : getConversations()) { for (Conversation conversation : getConversations()) {
deleted |= conversation.markAsDeleted(uuids); deleted |= conversation.markAsDeleted(uuids);
} }
for(final String uuid : uuids) {
evictPreview(uuid);
}
if (deleted) { if (deleted) {
updateConversationUi(); updateConversationUi();
} }
@ -4575,6 +4578,12 @@ public class XmppConnectionService extends Service {
sendIqPacket(account, set, null); sendIqPacket(account, set, null);
} }
public void evictPreview(String uuid) {
if (mBitmapCache.remove(uuid) != null) {
Log.d(Config.LOGTAG,"deleted cached preview");
}
}
public interface OnMamPreferencesFetched { public interface OnMamPreferencesFetched {
void onPreferencesFetched(Element prefs); void onPreferencesFetched(Element prefs);

View File

@ -1653,6 +1653,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
builder.setPositiveButton(R.string.confirm, (dialog, which) -> { builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
message.setDeleted(true); message.setDeleted(true);
activity.xmppConnectionService.evictPreview(message.getUuid());
activity.xmppConnectionService.updateMessage(message, false); activity.xmppConnectionService.updateMessage(message, false);
activity.onConversationsListItemUpdated(); activity.onConversationsListItemUpdated();
refresh(); refresh();