Skip to content

Commit a9bb37e

Browse files
committed
get proper file count of folders only when needed
1 parent d68aee2 commit a9bb37e

File tree

1 file changed

+5
-4
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments

1 file changed

+5
-4
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
233233

234234
val lastModifieds = context!!.getFolderLastModifieds(path)
235235
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
236+
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
236237
if (files != null) {
237238
for (file in files) {
238-
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds)
239+
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, getProperChildCount)
239240
if (fileDirItem != null) {
240241
items.add(fileDirItem)
241242
}
@@ -245,7 +246,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
245246
callback(path, items)
246247
}
247248

248-
private fun getFileDirItemFromFile(file: File, isSortingBySize: Boolean, lastModifieds: HashMap<String, Long>): ListItem? {
249+
private fun getFileDirItemFromFile(file: File, isSortingBySize: Boolean, lastModifieds: HashMap<String, Long>, getProperChildCount: Boolean): ListItem? {
249250
val curPath = file.absolutePath
250251
val curName = file.name
251252
if (!showHidden && curName.startsWith(".")) {
@@ -254,7 +255,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
254255

255256
var lastModified = lastModifieds.remove(curPath)
256257
val isDirectory = if (lastModified != null) false else file.isDirectory
257-
val children = if (isDirectory) file.getDirectChildrenCount(showHidden) else 0
258+
val children = if (isDirectory && getProperChildCount) file.getDirectChildrenCount(showHidden) else 0
258259
val size = if (isDirectory) {
259260
if (isSortingBySize) {
260261
file.getProperSize(showHidden)
@@ -380,7 +381,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
380381
files.addAll(searchFiles(text, it.absolutePath))
381382
} else {
382383
if (it.name.contains(text, true)) {
383-
val fileDirItem = getFileDirItemFromFile(it, isSortingBySize, HashMap<String, Long>())
384+
val fileDirItem = getFileDirItemFromFile(it, isSortingBySize, HashMap<String, Long>(), false)
384385
if (fileDirItem != null) {
385386
files.add(fileDirItem)
386387
}

0 commit comments

Comments
 (0)