add helper extension functions for scanning paths and files

This commit is contained in:
tibbi 2018-01-23 18:50:27 +01:00
parent 7105afbaa4
commit 561b56d81e
2 changed files with 22 additions and 1 deletions

View file

@ -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'
}

View file

@ -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<File>, callback: (() -> Unit)? = null) {
applicationContext.scanFiles(files, callback)
}
fun Activity.scanPaths(paths: ArrayList<String>, callback: (() -> Unit)? = null) {
applicationContext.scanPaths(paths, callback)
}
fun Activity.rescanPaths(paths: ArrayList<String>, 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)) {