call scanPath and scanFile on contexts only to avoid leaks

This commit is contained in:
tibbi 2018-01-23 18:40:29 +01:00
parent 5c3af88a4e
commit 96010b4c8e
5 changed files with 8 additions and 8 deletions

View file

@ -228,7 +228,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
private fun scanFinalPath(path: String) { private fun scanFinalPath(path: String) {
scanPath(path) { applicationContext.scanPath(path) {
setResult(Activity.RESULT_OK, intent) setResult(Activity.RESULT_OK, intent)
toast(R.string.file_saved) toast(R.string.file_saved)
finish() finish()

View file

@ -55,7 +55,7 @@ class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
config.addIncludedFolder(it) config.addIncludedFolder(it)
updateFolders() updateFolders()
Thread { Thread {
scanPath(it) applicationContext.scanPath(it)
}.start() }.start()
} }
} }

View file

@ -64,14 +64,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
if (mUri!!.scheme == "file") { if (mUri!!.scheme == "file") {
scanPath(mUri!!.path) applicationContext.scanPath(mUri!!.path)
sendViewPagerIntent(mUri!!.path) sendViewPagerIntent(mUri!!.path)
finish() finish()
return return
} else { } else {
val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms") { if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms") {
scanPath(mUri!!.path) applicationContext.scanPath(mUri!!.path)
sendViewPagerIntent(path) sendViewPagerIntent(path)
finish() finish()
return return

View file

@ -205,7 +205,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
reloadViewPager() reloadViewPager()
scanPath(mPath) applicationContext.scanPath(mPath)
if (config.blackBackground) { if (config.blackBackground) {
view_pager.background = ColorDrawable(Color.BLACK) view_pager.background = ColorDrawable(Color.BLACK)
@ -530,7 +530,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
deleteFile(newFile) deleteFile(newFile)
} }
copyFile(tmpFile, newFile) copyFile(tmpFile, newFile)
scanFile(newFile) applicationContext.scanFile(newFile)
toast(R.string.file_saved) toast(R.string.file_saved)
if (config.keepLastModified) { if (config.keepLastModified) {
@ -799,7 +799,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
deleteFile(file, true) deleteFile(file, true)
} }
scanPath(mDirectory) applicationContext.scanPath(mDirectory)
} }
private fun checkOrientation() { private fun checkOrientation() {

View file

@ -116,7 +116,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
} }
} }
scanFile(file) { applicationContext.scanFile(file) {
callback() callback()
} }
} }