add some null checks to obtaining directories
This commit is contained in:
parent
d1995d129a
commit
9773a481c8
1 changed files with 6 additions and 4 deletions
|
@ -54,7 +54,7 @@ fun Context.getParents(isPickImage: Boolean, isPickVideo: Boolean): ArrayList<St
|
||||||
cursor = contentResolver.query(uri, columns, where, args, null)
|
cursor = contentResolver.query(uri, columns, where, args, null)
|
||||||
if (cursor?.moveToFirst() == true) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
do {
|
do {
|
||||||
val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA)
|
val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA) ?: ""
|
||||||
parents.add(File(curPath).parent)
|
parents.add(File(curPath).parent)
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,10 @@ fun Context.getParents(isPickImage: Boolean, isPickVideo: Boolean): ArrayList<St
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
filterDirectories(parents)
|
val notNull = ArrayList<String>()
|
||||||
return parents
|
parents.mapNotNullTo(notNull, { it })
|
||||||
|
filterDirectories(notNull)
|
||||||
|
return notNull
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getWhereCondition(isPickImage: Boolean, isPickVideo: Boolean): String {
|
fun Context.getWhereCondition(isPickImage: Boolean, isPickVideo: Boolean): String {
|
||||||
|
@ -86,7 +88,7 @@ fun Context.getArgs(isPickImage: Boolean, isPickVideo: Boolean): Array<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.filterDirectories(dirs: MutableList<String>) {
|
fun Context.filterDirectories(dirs: ArrayList<String>) {
|
||||||
if (!config.showHiddenFolders) {
|
if (!config.showHiddenFolders) {
|
||||||
removeHiddenFolders(dirs)
|
removeHiddenFolders(dirs)
|
||||||
removeNoMediaFolders(dirs)
|
removeNoMediaFolders(dirs)
|
||||||
|
|
Loading…
Reference in a new issue