From 8256580ec2c8eb4b6b5b15004da638f9af110f5c Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 May 2019 21:44:27 +0200 Subject: [PATCH] replacing some recursive path scans with direct path scans --- .../simplemobiletools/gallery/pro/activities/EditActivity.kt | 2 +- .../gallery/pro/activities/PhotoVideoActivity.kt | 4 ++-- .../gallery/pro/activities/ViewPagerActivity.kt | 3 +-- .../com/simplemobiletools/gallery/pro/extensions/Activity.kt | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index aa4d554a6..425f382c7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -852,7 +852,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun scanFinalPath(path: String) { - scanPathRecursively(path) { + rescanPaths(arrayListOf(path)) { setResult(Activity.RESULT_OK, intent) toast(R.string.file_saved) finish() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index b8632b877..a596d86cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -108,7 +108,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (mUri!!.scheme == "file") { if (filename.contains('.')) { - scanPathRecursively(mUri!!.path) + rescanPaths(arrayListOf(mUri!!.path)) sendViewPagerIntent(mUri!!.path) finish() return @@ -116,7 +116,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } else { val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) { - scanPathRecursively(mUri!!.path) + rescanPaths(arrayListOf(mUri!!.path)) sendViewPagerIntent(path) finish() return 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 8d944e919..56db83d36 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 @@ -1017,9 +1017,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory) if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(true) == 0) { tryDeleteFileDirItem(fileDirItem, true, true) + scanPathRecursively(mDirectory) } - - scanPathRecursively(mDirectory) } private fun checkOrientation() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 921013ccc..8f2f23e97 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -169,7 +169,6 @@ fun BaseSimpleActivity.removeNoMedia(path: String, callback: (() -> Unit)? = nul } tryDeleteFileDirItem(file.toFileDirItem(applicationContext), false, false) { - scanPathRecursively(file.parent) callback?.invoke() } } @@ -437,7 +436,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String, } copyFile(tmpPath, newPath) - scanPathRecursively(newPath) + rescanPaths(arrayListOf(newPath)) fileRotatedSuccessfully(newPath, oldLastModified) it.flush()