mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
calculate proper folder size only if needed
This commit is contained in:
parent
633a1af644
commit
df3a0724d4
3 changed files with 12 additions and 10 deletions
|
@ -816,7 +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 getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0
|
||||||
val favoritePaths = getFavoritePaths()
|
val favoritePaths = getFavoritePaths()
|
||||||
val dirPathsToRemove = ArrayList<String>()
|
val dirPathsToRemove = ArrayList<String>()
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
directory
|
directory
|
||||||
} else {
|
} else {
|
||||||
createDirectoryFromMedia(directory.path, curMedia, albumCovers, hiddenString, includedFolders, isSortingAscending)
|
createDirectoryFromMedia(directory.path, curMedia, albumCovers, hiddenString, includedFolders, isSortingAscending, getProperFileSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we are looping through the already displayed folders looking for changes, do not do anything if nothing changed
|
// we are looping through the already displayed folders looking for changes, do not do anything if nothing changed
|
||||||
|
@ -913,7 +913,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, isSortingAscending)
|
val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, isSortingAscending, getProperFileSize)
|
||||||
dirs.add(newDir)
|
dirs.add(newDir)
|
||||||
setupAdapter(dirs)
|
setupAdapter(dirs)
|
||||||
try {
|
try {
|
||||||
|
@ -956,7 +956,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
private fun createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
||||||
includedFolders: MutableSet<String>, isSortingAscending: Boolean): Directory {
|
includedFolders: MutableSet<String>, isSortingAscending: Boolean, getProperFileSize: Boolean): Directory {
|
||||||
var thumbnail = curMedia.firstOrNull { File(it.path).exists() }?.path ?: ""
|
var thumbnail = curMedia.firstOrNull { File(it.path).exists() }?.path ?: ""
|
||||||
albumCovers.forEach {
|
albumCovers.forEach {
|
||||||
if (it.path == path && File(it.tmb).exists()) {
|
if (it.path == path && File(it.tmb).exists()) {
|
||||||
|
@ -969,7 +969,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
val dirName = checkAppendingHidden(path, hiddenString, includedFolders)
|
val dirName = checkAppendingHidden(path, hiddenString, includedFolders)
|
||||||
val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified)
|
val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified)
|
||||||
val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken)
|
val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken)
|
||||||
val size = curMedia.sumByLong { it.size }
|
val size = if (getProperFileSize) curMedia.sumByLong { it.size } else 0L
|
||||||
val mediaTypes = curMedia.getDirMediaTypes()
|
val mediaTypes = curMedia.getDirMediaTypes()
|
||||||
return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes)
|
return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ 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 getProperFileSize = context.config.getFileSorting(pathToUse) and SORT_BY_SIZE != 0
|
||||||
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) {
|
||||||
|
|
|
@ -165,8 +165,10 @@ class MediaFetcher(val context: Context) {
|
||||||
ArrayList()
|
ArrayList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val checkFileExistence = context.config.fileLoadingPriority == PRIORITY_VALIDITY
|
val config = context.config
|
||||||
val showHidden = context.config.shouldShowHidden
|
val checkProperFileSize = getProperFileSize || config.fileLoadingPriority == PRIORITY_COMPROMISE
|
||||||
|
val checkFileExistence = config.fileLoadingPriority == PRIORITY_VALIDITY
|
||||||
|
val showHidden = config.shouldShowHidden
|
||||||
val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap()
|
val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap()
|
||||||
|
|
||||||
val files = when (folder) {
|
val files = when (folder) {
|
||||||
|
@ -209,8 +211,8 @@ class MediaFetcher(val context: Context) {
|
||||||
if (!showHidden && filename.startsWith('.'))
|
if (!showHidden && filename.startsWith('.'))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val size = if (getProperFileSize || checkFileExistence) file.length() else 1L
|
val size = if (checkProperFileSize || checkFileExistence) file.length() else 1L
|
||||||
if ((getProperFileSize || checkFileExistence) && size <= 0L) {
|
if ((checkProperFileSize || checkFileExistence) && size <= 0L) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue