fix(scroller): Handle case when no visible items are found in VerticalFastScroller causing crash (#1077)
This commit is contained in:
parent
feabf6efa6
commit
888b0b0cbc
1 changed files with 8 additions and 2 deletions
|
|
@ -403,7 +403,10 @@ private fun computeScrollOffset(state: LazyListState): Int {
|
|||
if (state.layoutInfo.totalItemsCount == 0) return 0
|
||||
val visibleItems = state.layoutInfo.visibleItemsInfo
|
||||
val startChild = visibleItems
|
||||
.fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }!!
|
||||
.fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }
|
||||
// KMK -->
|
||||
?: return 0
|
||||
// KMK <--
|
||||
val endChild = visibleItems.last()
|
||||
val minPosition = min(startChild.index, endChild.index)
|
||||
val maxPosition = max(startChild.index, endChild.index)
|
||||
|
|
@ -419,7 +422,10 @@ private fun computeScrollRange(state: LazyListState): Int {
|
|||
if (state.layoutInfo.totalItemsCount == 0) return 0
|
||||
val visibleItems = state.layoutInfo.visibleItemsInfo
|
||||
val startChild = visibleItems
|
||||
.fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }!!
|
||||
.fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }
|
||||
// KMK -->
|
||||
?: return 0
|
||||
// KMK <--
|
||||
val endChild = visibleItems.last()
|
||||
val laidOutArea = endChild.bottom - startChild.top
|
||||
val laidOutRange = abs(startChild.index - endChild.index) + 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue