group the media files at querying the content resolver
This commit is contained in:
parent
638f4b4d45
commit
4ca455c761
|
@ -50,12 +50,13 @@ fun Context.launchSettings() {
|
||||||
|
|
||||||
fun Context.getParents(): ArrayList<String> {
|
fun Context.getParents(): ArrayList<String> {
|
||||||
val uri = MediaStore.Files.getContentUri("external")
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
val columns = arrayOf(MediaStore.Images.Media.DATA)
|
val columns = arrayOf(MediaStore.Files.FileColumns.PARENT, MediaStore.Images.Media.DATA)
|
||||||
|
val where = "${MediaStore.Images.Media.DATA} IS NOT NULL) GROUP BY (${MediaStore.Files.FileColumns.PARENT} "
|
||||||
val parentsSet = HashSet<String>()
|
val parentsSet = HashSet<String>()
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
try {
|
||||||
cursor = contentResolver.query(uri, columns, null, null, null)
|
cursor = contentResolver.query(uri, columns, where, null, null)
|
||||||
if (cursor?.moveToFirst() == true) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
do {
|
do {
|
||||||
val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA) ?: continue
|
val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA) ?: continue
|
||||||
|
|
Loading…
Reference in New Issue