@@ -241,13 +241,27 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
241241 val lastModifieds = context!! .getFolderLastModifieds(path)
242242
243243 for (file in files) {
244- val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, getProperChildCount )
244+ val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, false )
245245 if (fileDirItem != null ) {
246246 items.add(fileDirItem)
247247 }
248248 }
249249
250+ // send out the initial item list asap, get proper child count asynchronously as it can be slow
250251 callback(path, items)
252+
253+ if (getProperChildCount) {
254+ items.filter { it.mIsDirectory }.forEach {
255+ if (context != null ) {
256+ val childrenCount = it.getDirectChildrenCount(context!! , showHidden)
257+ if (childrenCount != 0 ) {
258+ activity?.runOnUiThread {
259+ getRecyclerAdapter()?.updateChildCount(it.mPath, childrenCount)
260+ }
261+ }
262+ }
263+ }
264+ }
251265 }
252266
253267 private fun getFileDirItemFromFile (file : File , isSortingBySize : Boolean , lastModifieds : HashMap <String , Long >, getProperChildCount : Boolean ): ListItem ? {
@@ -451,7 +465,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
451465
452466 private fun getRecyclerAdapter () = mView.items_list.adapter as ? ItemsAdapter
453467
454- fun setupLayoutManager () {
468+ private fun setupLayoutManager () {
455469 if (context!! .config.getFolderViewType(currentPath) == VIEW_TYPE_GRID ) {
456470 currentViewType = VIEW_TYPE_GRID
457471 setupGridLayoutManager()
0 commit comments