show subfolders count at the main screen, if grouping is enabled
This commit is contained in:
parent
3d47eac4e3
commit
9488795de8
|
@ -957,7 +957,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
private fun getDirsToShow(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||
return if (config.groupDirectSubfolders) {
|
||||
dirs.forEach { it.subfoldersMediaCount = it.mediaCnt }
|
||||
dirs.forEach {
|
||||
it.subfoldersCount = 1
|
||||
it.subfoldersMediaCount = it.mediaCnt
|
||||
}
|
||||
|
||||
val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet<String>
|
||||
val foldersToShow = getDirectParentSubfolders(dirFolders)
|
||||
val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
||||
|
@ -968,6 +972,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
var longestSharedPath = ""
|
||||
newDirs.forEach {
|
||||
if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) {
|
||||
it.subfoldersCount += 1
|
||||
longestSharedPath = it.path
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
private var showMediaCount = config.showMediaCount
|
||||
private var animateGifs = config.animateGifs
|
||||
private var cropThumbnails = config.cropThumbnails
|
||||
private var groupDirectSubfolders = config.groupDirectSubfolders
|
||||
private var currentDirectoriesHash = dirs.hashCode()
|
||||
|
||||
init {
|
||||
|
@ -501,7 +502,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
private fun setupView(view: View, directory: Directory) {
|
||||
val isSelected = selectedKeys.contains(directory.path.hashCode())
|
||||
view.apply {
|
||||
dir_name.text = directory.name
|
||||
dir_name.text = if (groupDirectSubfolders) "${directory.name} (${directory.subfoldersCount})" else directory.name
|
||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||
photo_cnt.text = directory.subfoldersMediaCount.toString()
|
||||
val thumbnailType = when {
|
||||
|
|
|
@ -22,9 +22,12 @@ data class Directory(
|
|||
@ColumnInfo(name = "size") var size: Long,
|
||||
@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)
|
||||
// used with "Group direct subfolders" enabled
|
||||
@Ignore var subfoldersCount: Int = 0,
|
||||
@Ignore var subfoldersMediaCount: Int = 0) {
|
||||
|
||||
constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, 0, 0)
|
||||
|
||||
fun getBubbleText(sorting: Int) = when {
|
||||
sorting and SORT_BY_NAME != 0 -> name
|
||||
|
|
Loading…
Reference in New Issue