home: use constant page limit

Use a constant page limit of 5 instead of a dynamic page limit.

This was not being properly updated prior, and since the ViewPager
already clamps it, the limit does not really need to be based on the
tab size anyway.
This commit is contained in:
Alexander Capehart 2023-06-07 20:07:06 -06:00
parent 8d97e86c8d
commit 77d01a0c97
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 6 additions and 4 deletions

View file

@ -52,6 +52,7 @@ import org.oxycblt.auxio.home.list.GenreListFragment
import org.oxycblt.auxio.home.list.PlaylistListFragment
import org.oxycblt.auxio.home.list.SongListFragment
import org.oxycblt.auxio.home.tabs.AdaptiveTabStrategy
import org.oxycblt.auxio.home.tabs.Tab
import org.oxycblt.auxio.list.Sort
import org.oxycblt.auxio.list.selection.SelectionFragment
import org.oxycblt.auxio.list.selection.SelectionViewModel
@ -152,9 +153,10 @@ class HomeFragment :
setOnApplyWindowInsetsListener { _, insets -> insets }
// We know that there will only be a fixed amount of tabs, so we manually set this
// limit to that. This also prevents the appbar lift state from being confused during
// page transitions.
offscreenPageLimit = homeModel.currentTabModes.size
// limit to the maximum amount possible. This will prevent the tab ripple from
// bugging out due to dynamically inflating each fragment, at the cost of slower
// debug UI performance.
offscreenPageLimit = Tab.MAX_SEQUENCE_IDX + 1
// By default, ViewPager2's sensitivity is high enough to result in vertical scroll
// events being registered as horizontal scroll events. Reflect into the internal

View file

@ -59,7 +59,7 @@ sealed class Tab(open val mode: MusicMode) {
// MusicMode for this tab.
/** The maximum index that a well-formed tab sequence should be. */
private const val MAX_SEQUENCE_IDX = 4
const val MAX_SEQUENCE_IDX = 4
/**
* The default tab sequence, in integer form. This represents a set of four visible tabs