small getMediaAsyncTask update
This commit is contained in:
parent
169b9f45ca
commit
4311529664
1 changed files with 6 additions and 7 deletions
|
@ -47,11 +47,10 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
|
||||||
private fun getFilesFrom(path: String): ArrayList<Medium> {
|
private fun getFilesFrom(path: String): ArrayList<Medium> {
|
||||||
val media = ArrayList<Medium>()
|
val media = ArrayList<Medium>()
|
||||||
val dir = File(path)
|
val dir = File(path)
|
||||||
val files = dir.listFiles() ?: return media
|
val filenames = dir.list() ?: return media
|
||||||
for (file in files) {
|
for (filename in filenames) {
|
||||||
val filePath = file.absolutePath
|
val isImage = filename.isImageFast() || filename.isGif()
|
||||||
val isImage = filePath.isImageFast() || filePath.isGif()
|
val isVideo = if (isImage) false else filename.isVideoFast()
|
||||||
val isVideo = if (isImage) false else filePath.isVideoFast()
|
|
||||||
|
|
||||||
if (!isImage && !isVideo)
|
if (!isImage && !isVideo)
|
||||||
continue
|
continue
|
||||||
|
@ -62,13 +61,13 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
|
||||||
if (isImage && (isPickVideo || showMedia == VIDEOS))
|
if (isImage && (isPickVideo || showMedia == VIDEOS))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
val file = File(path, 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()
|
||||||
media.add(Medium(name, filePath, isVideo, dateModified, dateModified, size))
|
media.add(Medium(filename, file.absolutePath, isVideo, dateModified, dateModified, size))
|
||||||
}
|
}
|
||||||
return media
|
return media
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue