properly include files from manually Included folders

This commit is contained in:
tibbi 2017-06-06 23:26:48 +02:00
parent 868a98acfa
commit 13620df112
1 changed files with 34 additions and 3 deletions

View File

@ -70,12 +70,11 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
val config = context.config val config = context.config
val showMedia = config.showMedia val showMedia = config.showMedia
val showHidden = config.shouldShowHidden val showHidden = config.shouldShowHidden
cur.use { cur ->
if (cur.moveToFirst()) {
val excludedFolders = config.excludedFolders val excludedFolders = config.excludedFolders
val noMediaFolders = context.getNoMediaFolders() val noMediaFolders = context.getNoMediaFolders()
cur.use { cur ->
if (cur.moveToFirst()) {
do { do {
try { try {
val path = cur.getStringValue(MediaStore.Images.Media.DATA) val path = cur.getStringValue(MediaStore.Images.Media.DATA)
@ -140,6 +139,38 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
} }
} }
if (curPath.isEmpty()) {
config.includedFolders.mapNotNull { File(it).listFiles() }.forEach {
for (file in it) {
val size = file.length()
if (size <= 0L) {
continue
}
val filename = file.name
val isImage = filename.isImageFast() || filename.isGif()
val isVideo = if (isImage) false else filename.isVideoFast()
if (!isImage && !isVideo)
continue
if (isVideo && (isPickImage || showMedia == IMAGES))
continue
if (isImage && (isPickVideo || showMedia == VIDEOS))
continue
val dateTaken = file.lastModified()
val dateModified = file.lastModified()
val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size)
val isAlreadyAdded = curMedia.any { it.path == file.absolutePath }
if (!isAlreadyAdded)
curMedia.add(medium)
}
}
}
Medium.sorting = config.getFileSorting(curPath) Medium.sorting = config.getFileSorting(curPath)
curMedia.sort() curMedia.sort()