diff --git a/app/build.gradle b/app/build.gradle index 42f9024db..bb8dd42ad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ ext { } dependencies { - compile 'com.simplemobiletools:commons:2.37.12' + compile 'com.simplemobiletools:commons:2.38.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.7.2' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' 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 f69f4f987..c6ccb0437 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt @@ -60,7 +60,7 @@ class IncludedFoldersActivity : SimpleActivity() { FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) { config.addIncludedFolder(it) updateIncludedFolders() - scanPath(it) {} + scanPath(it) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 62c143735..013311afc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -209,7 +209,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val newFolder = File(config.tempFolderPath) if (newFolder.exists() && newFolder.isDirectory) { if (newFolder.list()?.isEmpty() == true) { - deleteFileBg(newFolder, true) { } + deleteFileBg(newFolder, true) } } config.tempFolderPath = "" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index b500af01e..c26f78104 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -347,7 +347,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun deleteDirectoryIfEmpty() { val file = File(mPath) if (config.deleteEmptyFolders && !file.isDownloadsFolder() && file.isDirectory && file.listFiles()?.isEmpty() == true) { - deleteFile(file, true) {} + deleteFile(file, true) } } 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 960db4d14..20e8f48d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -59,14 +59,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) if (mUri!!.scheme == "file") { - scanPath(mUri!!.path) {} + scanPath(mUri!!.path) sendViewPagerIntent(mUri!!.path) finish() return } else { val path = applicationContext.getRealPathFromURI(mUri!!) ?: "" if (path != mUri.toString() && path.isNotEmpty()) { - scanPath(mUri!!.path) {} + 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 802f0eb9e..e808a8441 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -194,7 +194,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } reloadViewPager() - scanPath(mPath) {} + scanPath(mPath) if (config.darkBackground) view_pager.background = ColorDrawable(Color.BLACK) @@ -525,10 +525,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (tmpFile.length() > 0 && newFile.exists()) { - deleteFile(newFile) {} + deleteFile(newFile) } copyFile(tmpFile, newFile) - scanFile(newFile) {} + scanFile(newFile) toast(R.string.file_saved) if (config.keepLastModified) { @@ -553,7 +553,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } catch (e: Exception) { showErrorToast(e) } finally { - deleteFile(tmpFile) {} + deleteFile(tmpFile) } } @@ -794,10 +794,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun deleteDirectoryIfEmpty() { val file = File(mDirectory) if (config.deleteEmptyFolders && !file.isDownloadsFolder() && file.isDirectory && file.listFiles()?.isEmpty() == true) { - deleteFile(file, true) {} + deleteFile(file, true) } - scanPath(mDirectory) {} + scanPath(mDirectory) } private fun checkOrientation() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 039ac332a..2c1c3e012 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -173,7 +173,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, Thread({ getSelectedMedia().forEach { val oldFile = File(it.path) - activity.toggleFileVisibility(oldFile, hide) {} + activity.toggleFileVisibility(oldFile, hide) } activity.runOnUiThread { listener?.refreshItems() 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 200b2897b..0cfb3f900 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -116,14 +116,14 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) { } } -fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) { +fun SimpleActivity.removeNoMedia(path: String, callback: (() -> Unit)? = null) { val file = File(path, NOMEDIA) deleteFile(file) { - callback() + callback?.invoke() } } -fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: (newFile: File) -> Unit) { +fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: ((newFile: File) -> Unit)? = null) { val path = oldFile.parent var filename = oldFile.name filename = if (hide) { @@ -133,7 +133,7 @@ fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: } val newFile = File(path, filename) renameFile(oldFile, newFile) { - callback(newFile) + callback?.invoke(newFile) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index c42db1b4e..33e1fa98c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -282,7 +282,7 @@ class MediaFetcher(val context: Context) { val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } if (!isAlreadyAdded) { curMedia.add(medium) - context.scanPath(file.absolutePath) {} + context.scanPath(file.absolutePath) } } }