From 11fde4daa0d6d85622a6db74754032de9d8c5c07 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Jun 2018 12:30:55 +0200 Subject: [PATCH] fetch proper deletedTS at items in the recycle bin --- .../simplemobiletools/gallery/helpers/MediaFetcher.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 5a64f8f67..15e61bd10 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -162,9 +162,15 @@ class MediaFetcher(val context: Context) { favoritePaths: ArrayList): ArrayList { val media = ArrayList() + val deletedMedia = if (folder == RECYCLE_BIN) { + context.getUpdatedDeletedMedia(context.galleryDB.MediumDao()) + } else { + ArrayList() + } + val files = when (folder) { FAVORITES -> favoritePaths.map { File(it) }.toTypedArray() - RECYCLE_BIN -> context.getUpdatedDeletedMedia(context.galleryDB.MediumDao()).map { File(it.path) }.toTypedArray() + RECYCLE_BIN -> deletedMedia.map { File(it.path) }.toTypedArray() else -> File(folder).listFiles() ?: return media } @@ -221,7 +227,8 @@ class MediaFetcher(val context: Context) { val path = file.absolutePath val isFavorite = favoritePaths.contains(path) - val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite, 0L) + val deletedTS = if (folder == RECYCLE_BIN) deletedMedia.firstOrNull { it.path == path }?.deletedTS ?: 0L else 0L + val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite, deletedTS) media.add(medium) } return media