move cursor closing in the function using it

This commit is contained in:
tibbi 2017-05-28 23:17:06 +02:00
parent 18b714f9c3
commit a04d2d80b6

View file

@ -58,9 +58,7 @@ 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> {
@ -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()