catch exceptions at fetching media

This commit is contained in:
tibbi 2017-06-02 22:17:30 +02:00
parent 5a4b6065fb
commit ea42c4f1aa
1 changed files with 6 additions and 2 deletions

View File

@ -57,8 +57,12 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
val selection = if (curPath.isEmpty()) null else "(${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)"
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
try {
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
} catch (e: Exception) {
return ArrayList()
}
}
private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> {