add the slash after included/excluded folders at init
This commit is contained in:
parent
6b61883214
commit
c7307ce523
|
@ -59,11 +59,11 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
|
||||||
val selection = if (curPath.isEmpty()) null else "(${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)"
|
val selection = if (curPath.isEmpty()) null else "(${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)"
|
||||||
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
|
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
|
||||||
|
|
||||||
try {
|
return try {
|
||||||
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
|
||||||
return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
|
parseCursor(this, cur, isPickImage, isPickVideo, curPath)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return ArrayList()
|
ArrayList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
val config = context.config
|
val config = context.config
|
||||||
val filterMedia = config.filterMedia
|
val filterMedia = config.filterMedia
|
||||||
val showHidden = config.shouldShowHidden
|
val showHidden = config.shouldShowHidden
|
||||||
val includedFolders = config.includedFolders
|
val includedFolders = config.includedFolders.map { "$it/" }
|
||||||
val excludedFolders = config.excludedFolders
|
val excludedFolders = config.excludedFolders.map { "$it/" }
|
||||||
val noMediaFolders = context.getNoMediaFolders()
|
val noMediaFolders = context.getNoMediaFolders()
|
||||||
|
|
||||||
cur.use {
|
cur.use {
|
||||||
|
@ -115,10 +115,10 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
|
|
||||||
var isExcluded = false
|
var isExcluded = false
|
||||||
excludedFolders.forEach {
|
excludedFolders.forEach {
|
||||||
if (path.startsWith("$it/")) {
|
if (path.startsWith(it)) {
|
||||||
isExcluded = true
|
isExcluded = true
|
||||||
includedFolders.forEach {
|
includedFolders.forEach {
|
||||||
if (path.startsWith("$it/")) {
|
if (path.startsWith(it)) {
|
||||||
isExcluded = false
|
isExcluded = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,14 +193,12 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
|
|
||||||
fun Context.getSortingForFolder(path: String): String {
|
fun Context.getSortingForFolder(path: String): String {
|
||||||
val sorting = config.getFileSorting(path)
|
val sorting = config.getFileSorting(path)
|
||||||
val sortValue = if (sorting and SORT_BY_NAME > 0)
|
val sortValue = when {
|
||||||
MediaStore.Images.Media.DISPLAY_NAME
|
sorting and SORT_BY_NAME > 0 -> MediaStore.Images.Media.DISPLAY_NAME
|
||||||
else if (sorting and SORT_BY_SIZE > 0)
|
sorting and SORT_BY_SIZE > 0 -> MediaStore.Images.Media.SIZE
|
||||||
MediaStore.Images.Media.SIZE
|
sorting and SORT_BY_DATE_MODIFIED > 0 -> MediaStore.Images.Media.DATE_MODIFIED
|
||||||
else if (sorting and SORT_BY_DATE_MODIFIED > 0)
|
else -> MediaStore.Images.Media.DATE_TAKEN
|
||||||
MediaStore.Images.Media.DATE_MODIFIED
|
}
|
||||||
else
|
|
||||||
MediaStore.Images.Media.DATE_TAKEN
|
|
||||||
|
|
||||||
return if (sorting and SORT_DESCENDING > 0)
|
return if (sorting and SORT_DESCENDING > 0)
|
||||||
"$sortValue DESC"
|
"$sortValue DESC"
|
||||||
|
|
Loading…
Reference in New Issue