Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun onSubSharesScrolled() {
- val subSharesLm = subSharesRecyclerView.layoutManager as LinearLayoutManager
- val variantsLm = variantsRecyclerView.layoutManager as LinearLayoutManager
- val first = subSharesLm.findFirstVisibleItemPosition()
- val last = subSharesLm.findLastVisibleItemPosition()
- if (first < 0 || last < 0) {
- // When the list is empty, we get -1 for the positions.
- return
- }
- val firstId = verticalVariantIndexes[first]
- val lastId = verticalVariantIndexes[last]
- val range = verticalVariantIndexes.values.indexOf(firstId)..verticalVariantIndexes.values.indexOf(lastId)
- if (range != cachedRange) {
- cachedRange = highlightRange
- val selectedPosition = horizontalVariantIndexes[firstId]
- smoothScroller.targetPosition = selectedPosition ?: return
- variantsLm.startSmoothScroll(smoothScroller)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement