animate column count changes

This commit is contained in:
tibbi 2021-01-25 14:58:55 +01:00
parent d767098f20
commit 353618e5f4

View File

@ -506,7 +506,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
} }
} }
private fun calculateContentHeight(items: ArrayList<ListItem>) { private fun calculateContentHeight(items: MutableList<ListItem>) {
val layoutManager = mView.items_list.layoutManager as MyGridLayoutManager val layoutManager = mView.items_list.layoutManager as MyGridLayoutManager
val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0 val thumbnailHeight = layoutManager.getChildAt(0)?.height ?: 0
val fullHeight = ((items.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight val fullHeight = ((items.size - 1) / layoutManager.spanCount + 1) * thumbnailHeight
@ -525,8 +525,11 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
} }
private fun columnCountChanged() { private fun columnCountChanged() {
mView.items_list.adapter?.notifyDataSetChanged() activity?.invalidateOptionsMenu()
calculateContentHeight(storedItems) getRecyclerAdapter()?.apply {
notifyItemRangeChanged(0, listItems.size)
calculateContentHeight(listItems)
}
} }
fun toggleFilenameVisibility() { fun toggleFilenameVisibility() {