From 96010b4c8eee0f253eef82ca274885824906f85b Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 23 Jan 2018 18:40:29 +0100 Subject: [PATCH] call scanPath and scanFile on contexts only to avoid leaks --- .../simplemobiletools/gallery/activities/EditActivity.kt | 2 +- .../gallery/activities/IncludedFoldersActivity.kt | 2 +- .../gallery/activities/PhotoVideoActivity.kt | 4 ++-- .../gallery/activities/ViewPagerActivity.kt | 6 +++--- .../com/simplemobiletools/gallery/extensions/Activity.kt | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 8e3d4d6c4..4c2dc55f4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -228,7 +228,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun scanFinalPath(path: String) { - scanPath(path) { + applicationContext.scanPath(path) { setResult(Activity.RESULT_OK, intent) toast(R.string.file_saved) finish() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt index cb565c6b3..a7a3229b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt @@ -55,7 +55,7 @@ class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { config.addIncludedFolder(it) updateFolders() Thread { - scanPath(it) + applicationContext.scanPath(it) }.start() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index aba3b7060..c86e22888 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -64,14 +64,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) if (mUri!!.scheme == "file") { - scanPath(mUri!!.path) + applicationContext.scanPath(mUri!!.path) sendViewPagerIntent(mUri!!.path) finish() return } else { val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms") { - scanPath(mUri!!.path) + applicationContext.scanPath(mUri!!.path) sendViewPagerIntent(path) finish() return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 77557ea0b..30f8d5ae2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -205,7 +205,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } reloadViewPager() - scanPath(mPath) + applicationContext.scanPath(mPath) if (config.blackBackground) { view_pager.background = ColorDrawable(Color.BLACK) @@ -530,7 +530,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View deleteFile(newFile) } copyFile(tmpFile, newFile) - scanFile(newFile) + applicationContext.scanFile(newFile) toast(R.string.file_saved) if (config.keepLastModified) { @@ -799,7 +799,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View deleteFile(file, true) } - scanPath(mDirectory) + applicationContext.scanPath(mDirectory) } private fun checkOrientation() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt index e2780eb71..46a10186f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt @@ -116,7 +116,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) { } } - scanFile(file) { + applicationContext.scanFile(file) { callback() } }