rubensousa / DpadRecyclerView

A RecyclerView built for Android TV with Compose in mind and as a replacement for Leanback's BaseGridView.
https://rubensousa.github.io/DpadRecyclerView/
Apache License 2.0
136 stars 17 forks source link

Bug: Last row not getting focused while using DpadSpanSizeLookup #217

Closed tyrel-carlson closed 5 months ago

tyrel-carlson commented 5 months ago

I have a grid with a span count of 4 and also I have section date headers that fill the parent's width and aren't focusable. So the issue is that I can't focus on the last row of the grid.

here is how I config my DpadRecyclerView:

private fun setupRecyclerView(recycler: DpadRecyclerView) {
        recycler.adapter = adapter
        recycler.setSpanCount(SPAN_COUNT)

        recycler.setSpanSizeLookup(object : DpadSpanSizeLookup() {
            override fun getSpanSize(position: Int): Int {
                return if (position in 0 until adapter.itemCount && adapter.isSectionHeader(position)) SPAN_COUNT else 1
            }
        })

        recycler.attachListController(viewModel.listController)

        recycler.setSmoothScrollSpeedFactor(2f)
        recycler.setSmoothScrollMaxPendingMoves(1)
    }

I have fixed it using my own focusSearch, but you may want to fix it as well. Thanks!

rubensousa commented 5 months ago

Hi @tyrel-carlson. Fix should be here: https://github.com/rubensousa/DpadRecyclerView/pull/219

Thank you for the detailed bug reports, that really helps.