tweaking the getdirectories asynctask
This commit is contained in:
parent
b778e60781
commit
aab55cef62
1 changed files with 22 additions and 20 deletions
|
@ -28,12 +28,14 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
val fileSorting = config.fileSorting
|
val fileSorting = config.fileSorting
|
||||||
val parents = context.getParents()
|
val parents = context.getParents()
|
||||||
|
|
||||||
parents.map {
|
parents.forEach {
|
||||||
val paths = File(it).list()
|
val dir = File(it)
|
||||||
if (paths?.size ?: 0 > 0) {
|
if (dir.isDirectory) {
|
||||||
for (path in paths) {
|
val filenames = dir.list()
|
||||||
val isImage = path.isGif() or path.isImageFast()
|
if (filenames?.size ?: 0 > 0) {
|
||||||
val isVideo = if (isImage) false else path.isVideoFast()
|
for (filename in filenames) {
|
||||||
|
val isImage = filename.isImageFast() || filename.isGif()
|
||||||
|
val isVideo = if (isImage) false else filename.isVideoFast()
|
||||||
|
|
||||||
if (!isImage && !isVideo)
|
if (!isImage && !isVideo)
|
||||||
continue
|
continue
|
||||||
|
@ -44,18 +46,18 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
if (isImage && (isPickVideo || showMedia == VIDEOS))
|
if (isImage && (isPickVideo || showMedia == VIDEOS))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val file = File(it, path)
|
val file = File(it, filename)
|
||||||
val size = file.length()
|
val size = file.length()
|
||||||
if (size == 0L)
|
if (size == 0L)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val name = file.name
|
|
||||||
val dateModified = file.lastModified()
|
val dateModified = file.lastModified()
|
||||||
val medium = Medium(name, file.absolutePath, false, dateModified, dateModified, size)
|
val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateModified, size)
|
||||||
media.add(medium)
|
media.add(medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Medium.sorting = fileSorting
|
Medium.sorting = fileSorting
|
||||||
media.sort()
|
media.sort()
|
||||||
|
|
Loading…
Reference in a new issue