Skip to content

Commit

Permalink
Find first focusable view starting from adapter order
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Jun 4, 2024
1 parent 1b4a96c commit 0705ce0
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,10 @@ internal class PivotLayout(
}

private fun findFirstFocusableView(): View? {
val childCount = layoutInfo.getChildCount()
for (i in 0 until childCount) {
val actualIndex = if (layoutInfo.shouldReverseLayout()) {
childCount - 1 - i
} else {
i
}
val child = layoutInfo.getChildAt(actualIndex)
if (child != null && child.hasFocusable()) {
return child
for (i in 0 until layoutManager.itemCount) {
val view = layoutInfo.findViewByAdapterPosition(i)
if (view != null && layoutInfo.isViewFocusable(view)) {
return view
}
}
return null
Expand Down

0 comments on commit 0705ce0

Please sign in to comment.