From ff6726b47601f0772fc4bf3eceaebf8f02d301f9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 9 Oct 2021 17:38:38 +0200 Subject: [PATCH] lets rescan files after some file operations, reverting #4d00682ec6 --- .../pro/activities/ViewPagerActivity.kt | 14 +++++--- .../gallery/pro/adapters/DirectoryAdapter.kt | 32 +++++++++++++------ .../gallery/pro/adapters/MediaAdapter.kt | 4 ++- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 0fe226c5d..91408e621 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -631,7 +631,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val fileDirItems = arrayListOf(FileDirItem(currPath, currPath.getFilenameFromPath())) tryCopyMoveFilesTo(fileDirItems, isCopyOperation) { val newPath = "$it/${currPath.getFilenameFromPath()}" - fixDateTaken(arrayListOf(newPath), false) + rescanPaths(arrayListOf(newPath)) { + fixDateTaken(arrayListOf(newPath), false) + } config.tempFolderPath = "" if (!isCopyOperation) { @@ -1029,11 +1031,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View toast(R.string.file_saved) val paths = arrayListOf(file.absolutePath) - fixDateTaken(paths, false) + rescanPaths(paths) { + fixDateTaken(paths, false) - if (config.keepLastModified) { - File(file.absolutePath).setLastModified(lastModified) - updateLastModified(file.absolutePath, lastModified) + if (config.keepLastModified) { + File(file.absolutePath).setLastModified(lastModified) + updateLastModified(file.absolutePath, lastModified) + } } out.close() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 1d96317cc..1011ea2cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -54,8 +54,10 @@ import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap -class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView, - val isPickIntent: Boolean, val swipeRefreshLayout: SwipeRefreshLayout? = null, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) : +class DirectoryAdapter( + activity: BaseSimpleActivity, var dirs: ArrayList, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView, + val isPickIntent: Boolean, val swipeRefreshLayout: SwipeRefreshLayout? = null, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit +) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick), ItemTouchHelperContract { private val config = activity.config @@ -457,10 +459,11 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList if (success) { - paths.filter { config.isFolderProtected(it) && config.getFolderProtectionType(it) == tabToShow && config.getFolderProtectionHash(it) == hashToCheck }.forEach { - config.removeFolderProtection(it) - lockedFolderPaths.remove(it) - } + paths.filter { config.isFolderProtected(it) && config.getFolderProtectionType(it) == tabToShow && config.getFolderProtectionHash(it) == hashToCheck } + .forEach { + config.removeFolderProtection(it) + lockedFolderPaths.remove(it) + } listener?.refreshItems() finishActMode() @@ -522,8 +525,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) { val destinationPath = it - val newPaths = fileDirItems.map { "$destinationPath/${it.name}" }.toMutableList() as java.util.ArrayList - activity.fixDateTaken(newPaths, false) + val newPaths = fileDirItems.map { "$destinationPath/${it.name}" }.toMutableList() as ArrayList + activity.rescanPaths(newPaths) { + activity.fixDateTaken(newPaths, false) + } config.tempFolderPath = "" listener?.refreshItems() @@ -788,7 +793,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList ROUNDED_CORNERS_BIG } - activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, directory.getKey()) + activity.loadImage( + thumbnailType, + directory.tmb, + dir_thumbnail, + scrollHorizontally, + animateGifs, + cropThumbnails, + roundedCorners, + directory.getKey() + ) } dir_pin.beVisibleIf(pinnedFolders.contains(directory.path)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index d558b1d24..f052d1d7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -357,7 +357,9 @@ class MediaAdapter( activity.applicationContext.rescanFolderMedia(fileDirItems.first().getParentPath()) val newPaths = fileDirItems.map { "$destinationPath/${it.name}" }.toMutableList() as ArrayList - activity.fixDateTaken(newPaths, false) + activity.rescanPaths(newPaths) { + activity.fixDateTaken(newPaths, false) + } if (!isCopyOperation) { listener?.refreshItems()