move cursor closing in the function using it
This commit is contained in:
parent
18b714f9c3
commit
a04d2d80b6
1 changed files with 64 additions and 64 deletions
|
@ -58,10 +58,8 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
|
|||
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
|
||||
|
||||
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
||||
cur.use { cur ->
|
||||
return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> {
|
||||
val curMedia = ArrayList<Medium>()
|
||||
|
@ -69,6 +67,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
|||
val showMedia = config.showMedia
|
||||
val showHidden = config.shouldShowHidden
|
||||
|
||||
cur.use { cur ->
|
||||
if (cur.moveToFirst()) {
|
||||
var filename: String
|
||||
var path: String
|
||||
|
@ -142,6 +141,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
|||
}
|
||||
} while (cur.moveToNext())
|
||||
}
|
||||
}
|
||||
|
||||
Medium.sorting = config.getFileSorting(curPath)
|
||||
curMedia.sort()
|
||||
|
|
Loading…
Reference in a new issue