From 561b56d81e01eb1a0a124ce46efeb1947a7cc877 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 23 Jan 2018 18:50:27 +0100 Subject: [PATCH] add helper extension functions for scanning paths and files --- build.gradle | 2 +- .../commons/extensions/Activity.kt | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1d1200d52..9a893d437 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '3.8.1' + propVersionName = '3.8.2' kotlin_version = '1.2.20' support_libs = '27.0.2' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index b5006740b..10313a1ea 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -458,6 +458,27 @@ private fun deleteRecursively(file: File): Boolean { return file.delete() } + +fun Activity.scanFile(file: File, callback: (() -> Unit)? = null) { + applicationContext.scanFile(file, callback) +} + +fun Activity.scanPath(path: String, callback: (() -> Unit)? = null) { + applicationContext.scanPath(path, callback) +} + +fun Activity.scanFiles(files: ArrayList, callback: (() -> Unit)? = null) { + applicationContext.scanFiles(files, callback) +} + +fun Activity.scanPaths(paths: ArrayList, callback: (() -> Unit)? = null) { + applicationContext.scanPaths(paths, callback) +} + +fun Activity.rescanPaths(paths: ArrayList, callback: (() -> Unit)? = null) { + applicationContext.rescanPaths(paths, callback) +} + @SuppressLint("NewApi") fun BaseSimpleActivity.renameFile(oldFile: File, newFile: File, callback: ((success: Boolean) -> Unit)? = null) { if (needsStupidWritePermissions(newFile.absolutePath)) {