Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with D-pad navigation #40

Open
joharei opened this issue Jul 30, 2017 · 0 comments
Open

Problems with D-pad navigation #40

joharei opened this issue Jul 30, 2017 · 0 comments

Comments

@joharei
Copy link

joharei commented Jul 30, 2017

I'm using the library in an Android TV app, so navigation with D-pad is a requirement for me. When I press down in a list, the focusing works correctly until I reach the last displayed row. Pressing down from there does nothing, and onFocusSearchFailed() is called in the layout manager.

I've worked around this by subclassing the layout manager and scrolling a little when the focus search fails:

override fun onFocusSearchFailed(focused: View, focusDirection: Int,
                                 recycler: RecyclerView.Recycler, state: RecyclerView.State): View? {
    // Need to be called in order to layout new row
    scrollVerticallyBy(when (focusDirection) {
        View.FOCUS_DOWN -> 10
        View.FOCUS_UP -> -10
        else -> 0
    }, recycler, state)

    return super.onFocusSearchFailed(focused, focusDirection, recycler, state)
}

But there is probably a better way to do this.

Thanks for the nice library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant