From 46533e4b454e0872e47b8f2625fce1f9dc5e59f9 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sat, 18 Jun 2022 14:35:04 +0530 Subject: [PATCH] Minor code improvements --- .../gallery/pro/extensions/Context.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 37cf10e26..774c1d90c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -373,18 +373,16 @@ fun Context.rescanFolderMedia(path: String) { } fun Context.rescanFolderMediaSync(path: String) { - getCachedMedia(path) { - val cached = it - GetMediaAsynctask(applicationContext, path, false, false, false) { + getCachedMedia(path) { cached -> + GetMediaAsynctask(applicationContext, path, isPickImage = false, isPickVideo = false, showAll = false) { newMedia -> ensureBackgroundThread { - val newMedia = it - val media = newMedia.filter { it is Medium } as ArrayList + val media = newMedia.filterIsInstance() as ArrayList try { mediaDB.insertAll(media) - cached.forEach { - if (!newMedia.contains(it)) { - val mediumPath = (it as? Medium)?.path + cached.forEach { thumbnailItem -> + if (!newMedia.contains(thumbnailItem)) { + val mediumPath = (thumbnailItem as? Medium)?.path if (mediumPath != null) { deleteDBPath(mediumPath) }