take selected file loading priority into consideration at loading files
This commit is contained in:
parent
ec5c902fb7
commit
f4ea041a8b
|
@ -816,6 +816,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
val tempFolderPath = config.tempFolderPath
|
val tempFolderPath = config.tempFolderPath
|
||||||
val isSortingAscending = config.directorySorting and SORT_DESCENDING == 0
|
val isSortingAscending = config.directorySorting and SORT_DESCENDING == 0
|
||||||
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0
|
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0
|
||||||
|
val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0 || config.fileLoadingPriority == PRIORITY_COMPROMISE
|
||||||
val favoritePaths = getFavoritePaths()
|
val favoritePaths = getFavoritePaths()
|
||||||
val dirPathsToRemove = ArrayList<String>()
|
val dirPathsToRemove = ArrayList<String>()
|
||||||
|
|
||||||
|
@ -825,7 +826,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val curMedia = mediaFetcher.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, favoritePaths, false)
|
val curMedia = mediaFetcher.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||||
val newDir = if (curMedia.isEmpty()) {
|
val newDir = if (curMedia.isEmpty()) {
|
||||||
if (directory.path != tempFolderPath) {
|
if (directory.path != tempFolderPath) {
|
||||||
dirPathsToRemove.add(directory.path)
|
dirPathsToRemove.add(directory.path)
|
||||||
|
@ -898,7 +899,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val newMedia = mediaFetcher.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, favoritePaths, false)
|
val newMedia = mediaFetcher.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false)
|
||||||
if (newMedia.isEmpty()) {
|
if (newMedia.isEmpty()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.pro.asynctasks
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.getFavoritePaths
|
import com.simplemobiletools.gallery.pro.extensions.getFavoritePaths
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
|
@ -18,20 +19,21 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
||||||
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
||||||
val pathToUse = if (showAll) SHOW_ALL else mPath
|
val pathToUse = if (showAll) SHOW_ALL else mPath
|
||||||
val getProperDateTaken = context.config.getFileSorting(pathToUse) and SORT_BY_DATE_TAKEN != 0 || context.config.getFolderGrouping(pathToUse) and GROUP_BY_DATE_TAKEN != 0
|
val getProperDateTaken = context.config.getFileSorting(pathToUse) and SORT_BY_DATE_TAKEN != 0 || context.config.getFolderGrouping(pathToUse) and GROUP_BY_DATE_TAKEN != 0
|
||||||
|
val getProperFileSize = context.config.getFileSorting(pathToUse) and SORT_BY_SIZE != 0 || context.config.fileLoadingPriority == PRIORITY_COMPROMISE
|
||||||
val favoritePaths = context.getFavoritePaths()
|
val favoritePaths = context.getFavoritePaths()
|
||||||
val getVideoDurations = context.config.showThumbnailVideoDuration
|
val getVideoDurations = context.config.showThumbnailVideoDuration
|
||||||
val media = if (showAll) {
|
val media = if (showAll) {
|
||||||
val foldersToScan = mediaFetcher.getFoldersToScan().filter { it != RECYCLE_BIN && it != FAVORITES }
|
val foldersToScan = mediaFetcher.getFoldersToScan().filter { it != RECYCLE_BIN && it != FAVORITES }
|
||||||
val media = ArrayList<Medium>()
|
val media = ArrayList<Medium>()
|
||||||
foldersToScan.forEach {
|
foldersToScan.forEach {
|
||||||
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken, favoritePaths, getVideoDurations, false)
|
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken, getProperFileSize, favoritePaths, getVideoDurations, false)
|
||||||
media.addAll(newMedia)
|
media.addAll(newMedia)
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaFetcher.sortMedia(media, context.config.getFileSorting(SHOW_ALL))
|
mediaFetcher.sortMedia(media, context.config.getFileSorting(SHOW_ALL))
|
||||||
media
|
media
|
||||||
} else {
|
} else {
|
||||||
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, favoritePaths, getVideoDurations)
|
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, getProperFileSize, favoritePaths, getVideoDurations)
|
||||||
}
|
}
|
||||||
return mediaFetcher.groupMedia(media, pathToUse)
|
return mediaFetcher.groupMedia(media, pathToUse)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,15 @@ import java.util.*
|
||||||
class MediaFetcher(val context: Context) {
|
class MediaFetcher(val context: Context) {
|
||||||
var shouldStop = false
|
var shouldStop = false
|
||||||
|
|
||||||
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, favoritePaths: ArrayList<String>,
|
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, getProperFileSize: Boolean,
|
||||||
getVideoDurations: Boolean, sortMedia: Boolean = true): ArrayList<Medium> {
|
favoritePaths: ArrayList<String>, getVideoDurations: Boolean, sortMedia: Boolean = true): ArrayList<Medium> {
|
||||||
val filterMedia = context.config.filterMedia
|
val filterMedia = context.config.filterMedia
|
||||||
if (filterMedia == 0) {
|
if (filterMedia == 0) {
|
||||||
return ArrayList()
|
return ArrayList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val curMedia = ArrayList<Medium>()
|
val curMedia = ArrayList<Medium>()
|
||||||
val newMedia = getMediaInFolder(curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, favoritePaths, getVideoDurations)
|
val newMedia = getMediaInFolder(curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, getProperFileSize, favoritePaths, getVideoDurations)
|
||||||
curMedia.addAll(newMedia)
|
curMedia.addAll(newMedia)
|
||||||
|
|
||||||
if (sortMedia) {
|
if (sortMedia) {
|
||||||
|
@ -155,7 +155,7 @@ class MediaFetcher(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMediaInFolder(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, getProperDateTaken: Boolean,
|
private fun getMediaInFolder(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, getProperDateTaken: Boolean,
|
||||||
favoritePaths: ArrayList<String>, getVideoDurations: Boolean): ArrayList<Medium> {
|
getProperFileSize: Boolean, favoritePaths: ArrayList<String>, getVideoDurations: Boolean): ArrayList<Medium> {
|
||||||
val media = ArrayList<Medium>()
|
val media = ArrayList<Medium>()
|
||||||
|
|
||||||
val isRecycleBin = folder == RECYCLE_BIN
|
val isRecycleBin = folder == RECYCLE_BIN
|
||||||
|
@ -209,9 +209,14 @@ class MediaFetcher(val context: Context) {
|
||||||
if (!showHidden && filename.startsWith('.'))
|
if (!showHidden && filename.startsWith('.'))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val size = file.length()
|
val size = if (getProperFileSize || checkFileExistence) file.length() else 1L
|
||||||
if (size <= 0L || (checkFileExistence && !file.exists()))
|
if ((getProperFileSize || checkFileExistence) && size <= 0L) {
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkFileExistence && !file.exists()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if (isRecycleBin) {
|
if (isRecycleBin) {
|
||||||
deletedMedia.firstOrNull { it.path == path }?.apply {
|
deletedMedia.firstOrNull { it.path == path }?.apply {
|
||||||
|
@ -356,7 +361,7 @@ class MediaFetcher(val context: Context) {
|
||||||
return if (timestamp.areDigitsOnly()) {
|
return if (timestamp.areDigitsOnly()) {
|
||||||
val cal = Calendar.getInstance(Locale.ENGLISH)
|
val cal = Calendar.getInstance(Locale.ENGLISH)
|
||||||
cal.timeInMillis = timestamp.toLong()
|
cal.timeInMillis = timestamp.toLong()
|
||||||
return DateFormat.format("dd MMM yyyy", cal).toString()
|
DateFormat.format("dd MMM yyyy", cal).toString()
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue