Skip to content

Commit d14cf23

Browse files
committed
recalculate the list height in some cases
1 parent af5862f commit d14cf23

File tree

1 file changed

+10
-0
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
189189
getRecyclerLayoutManager().onRestoreInstanceState(scrollStates[currentPath])
190190
items_list.onGlobalLayout {
191191
items_fastscroller.setScrollToY(items_list.computeVerticalScrollOffset())
192+
calculateContentHeight(storedItems)
192193
}
193194
}
194195
}
@@ -469,6 +470,14 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
469470
}
470471
}
471472

473+
private fun calculateContentHeight(items: ArrayList<ListItem>) {
474+
val layoutManager = mView.items_list.layoutManager as MyGridLayoutManager
475+
val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0
476+
val fullHeight = ((items.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
477+
mView.items_fastscroller.setContentHeight(fullHeight)
478+
mView.items_fastscroller.setScrollToY(mView.items_list.computeVerticalScrollOffset())
479+
}
480+
472481
fun increaseColumnCount() {
473482
context?.config?.fileColumnCnt = ++(mView.items_list.layoutManager as MyGridLayoutManager).spanCount
474483
columnCountChanged()
@@ -481,6 +490,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
481490

482491
private fun columnCountChanged() {
483492
mView.items_list.adapter?.notifyDataSetChanged()
493+
calculateContentHeight(storedItems)
484494
}
485495

486496
override fun breadcrumbClicked(id: Int) {

0 commit comments

Comments
 (0)