diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt index 0067953da..bac04000f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt @@ -2,17 +2,21 @@ package com.simplemobiletools.gallery.pro.asynctasks import android.content.Context import android.os.AsyncTask -import com.simplemobiletools.commons.helpers.* +import com.simplemobiletools.commons.helpers.FAVORITES +import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED +import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN +import com.simplemobiletools.commons.helpers.SORT_BY_SIZE import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.getFavoritePaths import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem -import java.util.* -class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage: Boolean = false, val isPickVideo: Boolean = false, - val showAll: Boolean, val callback: (media: ArrayList) -> Unit) : - AsyncTask>() { +class GetMediaAsynctask( + val context: Context, val mPath: String, val isPickImage: Boolean = false, val isPickVideo: Boolean = false, + val showAll: Boolean, val callback: (media: ArrayList) -> Unit +) : + AsyncTask>() { private val mediaFetcher = MediaFetcher(context) override fun doInBackground(vararg params: Void): ArrayList { @@ -20,12 +24,12 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage val folderGrouping = context.config.getFolderGrouping(pathToUse) val folderSorting = context.config.getFolderSorting(pathToUse) val getProperDateTaken = folderSorting and SORT_BY_DATE_TAKEN != 0 || - folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || - folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 val getProperLastModified = folderSorting and SORT_BY_DATE_MODIFIED != 0 || - folderGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || - folderGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 + folderGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + folderGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 val getProperFileSize = folderSorting and SORT_BY_SIZE != 0 val favoritePaths = context.getFavoritePaths() @@ -37,16 +41,20 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage val foldersToScan = mediaFetcher.getFoldersToScan().filter { it != RECYCLE_BIN && it != FAVORITES && !context.config.isFolderProtected(it) } val media = ArrayList() foldersToScan.forEach { - val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken, getProperLastModified, getProperFileSize, - favoritePaths, getVideoDurations, lastModifieds, dateTakens.clone() as HashMap, null) + val newMedia = mediaFetcher.getFilesFrom( + it, isPickImage, isPickVideo, getProperDateTaken, getProperLastModified, getProperFileSize, + favoritePaths, getVideoDurations, lastModifieds, dateTakens.clone() as HashMap, null + ) media.addAll(newMedia) } mediaFetcher.sortMedia(media, context.config.getFolderSorting(SHOW_ALL)) media } else { - mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, - getVideoDurations, lastModifieds, dateTakens, null) + mediaFetcher.getFilesFrom( + mPath, isPickImage, isPickVideo, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, + getVideoDurations, lastModifieds, dateTakens, null + ) } return mediaFetcher.groupMedia(media, pathToUse)