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 selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
|
||||||
|
|
||||||
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
||||||
cur.use { cur ->
|
|
||||||
return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
|
return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> {
|
private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> {
|
||||||
val curMedia = 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 showMedia = config.showMedia
|
||||||
val showHidden = config.shouldShowHidden
|
val showHidden = config.shouldShowHidden
|
||||||
|
|
||||||
|
cur.use { cur ->
|
||||||
if (cur.moveToFirst()) {
|
if (cur.moveToFirst()) {
|
||||||
var filename: String
|
var filename: String
|
||||||
var path: String
|
var path: String
|
||||||
|
@ -142,6 +141,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
}
|
}
|
||||||
} while (cur.moveToNext())
|
} while (cur.moveToNext())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Medium.sorting = config.getFileSorting(curPath)
|
Medium.sorting = config.getFileSorting(curPath)
|
||||||
curMedia.sort()
|
curMedia.sort()
|
||||||
|
|
Loading…
Reference in a new issue