From cedb2475835fc2e96dd2a340de69e096216b48da Mon Sep 17 00:00:00 2001 From: Jingwei Hao Date: Tue, 17 Oct 2023 12:23:17 -0700 Subject: [PATCH] Fix crash on scroll position restoration --- .../kotlin/app/cash/redwood/lazylayout/view/ViewLazyList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redwood-lazylayout-view/src/main/kotlin/app/cash/redwood/lazylayout/view/ViewLazyList.kt b/redwood-lazylayout-view/src/main/kotlin/app/cash/redwood/lazylayout/view/ViewLazyList.kt index c28013ead2..98a17787c1 100644 --- a/redwood-lazylayout-view/src/main/kotlin/app/cash/redwood/lazylayout/view/ViewLazyList.kt +++ b/redwood-lazylayout-view/src/main/kotlin/app/cash/redwood/lazylayout/view/ViewLazyList.kt @@ -107,7 +107,7 @@ internal open class ViewLazyList private constructor( val viewsOnScreen = recyclerView.children.map { recyclerView.getChildViewHolder(it).bindingAdapterPosition } userHasScrolled = true // Prevent guest code from hijacking the scrollbar. onViewportChanged?.invoke( - viewsOnScreen.min(), + viewsOnScreen.min().coerceAtLeast(0), viewsOnScreen.max(), ) }