From 43115296648a0d02b25d7ea1881fc3ea544fe61f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 Feb 2017 17:28:21 +0100 Subject: [PATCH] small getMediaAsyncTask update --- .../gallery/asynctasks/GetMediaAsynctask.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index 82e086d31..c6483cce1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -47,11 +47,10 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo private fun getFilesFrom(path: String): ArrayList { val media = ArrayList() val dir = File(path) - val files = dir.listFiles() ?: return media - for (file in files) { - val filePath = file.absolutePath - val isImage = filePath.isImageFast() || filePath.isGif() - val isVideo = if (isImage) false else filePath.isVideoFast() + val filenames = dir.list() ?: return media + for (filename in filenames) { + val isImage = filename.isImageFast() || filename.isGif() + val isVideo = if (isImage) false else filename.isVideoFast() if (!isImage && !isVideo) continue @@ -62,13 +61,13 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo if (isImage && (isPickVideo || showMedia == VIDEOS)) continue + val file = File(path, filename) val size = file.length() if (size == 0L) continue - val name = file.name 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 }