mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 14:28:00 +01:00
ignore the root folders at fetching media
This commit is contained in:
parent
dfdfd88941
commit
373e06c98f
1 changed files with 23 additions and 2 deletions
|
@ -89,8 +89,8 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
|
||||||
MediaStore.Images.Media.DATA,
|
MediaStore.Images.Media.DATA,
|
||||||
MediaStore.Images.Media.SIZE)
|
MediaStore.Images.Media.SIZE)
|
||||||
val uri = MediaStore.Files.getContentUri("external")
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
val selection = if (curPath.isEmpty()) null else "(${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)"
|
val selection = getSelectionQuery(curPath)
|
||||||
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
|
val selectionArgs = getSelectionArgsQuery(curPath)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
||||||
|
@ -100,6 +100,27 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.getSelectionQuery(path: String): String {
|
||||||
|
val dataQuery = "${MediaStore.Images.Media.DATA} LIKE ?"
|
||||||
|
return if (path.isEmpty()) {
|
||||||
|
var query = "($dataQuery)"
|
||||||
|
if (hasExternalSDCard()) {
|
||||||
|
query += " OR ($dataQuery)"
|
||||||
|
}
|
||||||
|
query
|
||||||
|
} else {
|
||||||
|
"($dataQuery AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.getSelectionArgsQuery(path: String): Array<String> {
|
||||||
|
return if (path.isEmpty()) {
|
||||||
|
if (hasExternalSDCard()) arrayOf("$internalStoragePath/%", "$sdCardPath/%") else arrayOf("$internalStoragePath/%")
|
||||||
|
} else {
|
||||||
|
arrayOf("$path/%", "$path/%/%")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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>()
|
||||||
val config = context.config
|
val config = context.config
|
||||||
|
|
Loading…
Reference in a new issue