mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
show the sum of all subfolder media counts with "Group direct subfolders"
This commit is contained in:
parent
74cfe5167e
commit
3d47eac4e3
3 changed files with 28 additions and 8 deletions
|
@ -957,10 +957,30 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
private fun getDirsToShow(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||
return if (config.groupDirectSubfolders) {
|
||||
dirs.forEach { it.subfoldersMediaCount = it.mediaCnt }
|
||||
val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet<String>
|
||||
val foldersToShow = getDirectParentSubfolders(dirFolders)
|
||||
dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
||||
val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
||||
|
||||
// update the directory media counts, add all subfolder media counts to it
|
||||
dirs.forEach {
|
||||
val mainDir = it
|
||||
var longestSharedPath = ""
|
||||
newDirs.forEach {
|
||||
if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) {
|
||||
longestSharedPath = it.path
|
||||
}
|
||||
}
|
||||
|
||||
val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath }
|
||||
if (mainFolder != null) {
|
||||
mainFolder.subfoldersMediaCount += mainDir.mediaCnt
|
||||
}
|
||||
}
|
||||
|
||||
newDirs
|
||||
} else {
|
||||
dirs.forEach { it.subfoldersMediaCount = it.mediaCnt }
|
||||
dirs
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
view.apply {
|
||||
dir_name.text = directory.name
|
||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||
photo_cnt.text = directory.mediaCnt.toString()
|
||||
photo_cnt.text = directory.subfoldersMediaCount.toString()
|
||||
val thumbnailType = when {
|
||||
directory.tmb.isVideoFast() -> TYPE_VIDEOS
|
||||
directory.tmb.isGif() -> TYPE_GIFS
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.simplemobiletools.gallery.pro.models
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import androidx.room.*
|
||||
import com.simplemobiletools.commons.extensions.formatDate
|
||||
import com.simplemobiletools.commons.extensions.formatSize
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
|
||||
|
@ -23,8 +20,11 @@ data class Directory(
|
|||
@ColumnInfo(name = "last_modified") var modified: Long,
|
||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||
@ColumnInfo(name = "size") var size: Long,
|
||||
@ColumnInfo(name = "location") val location: Int,
|
||||
@ColumnInfo(name = "media_types") var types: Int) {
|
||||
@ColumnInfo(name = "location") var location: Int,
|
||||
@ColumnInfo(name = "media_types") var types: Int,
|
||||
@Ignore var subfoldersMediaCount: Int = 0) { // used with "Group direct subfolders" enabled to count subfolder media counts
|
||||
|
||||
constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, 0)
|
||||
|
||||
fun getBubbleText(sorting: Int) = when {
|
||||
sorting and SORT_BY_NAME != 0 -> name
|
||||
|
|
Loading…
Reference in a new issue