Skip to content

Commit

Permalink
Cancel scrolling to target before updating the layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Sep 26, 2024
1 parent 3e6044b commit 05536f5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ class PivotLayoutManager(properties: Properties) : RecyclerView.LayoutManager(),
override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
// If we have focus, save it temporarily since the views will change and we might lose it
hadFocusBeforeLayout = hasFocus()
if (layoutInfo.isScrollingToTarget) {
scroller.cancelScrollToTarget()
}
pivotLayout.onLayoutChildren(recycler, state)
if (hadFocusBeforeLayout) {
focusDispatcher.focusSelectedView()
}
if (layoutInfo.isScrollingToTarget) {
scroller.cancelScrollToTarget()
}
hadFocusBeforeLayout = false
}

Expand Down

0 comments on commit 05536f5

Please sign in to comment.