egeniq / android-tv-program-guide

Android TV Program Guide
Apache License 2.0
164 stars 66 forks source link

Focus issue #32

Closed psandroiddev closed 3 years ago

psandroiddev commented 3 years ago

In my app there is toolbar at top so when I open the activity first time focus goes to the Search icon & then goes down to the particular current program with focus .But I want initially focus goes to current program not to the Search icon on toolbar.

dzolnai commented 3 years ago

Did you try calling .requestFocus on the grid?

psandroiddev commented 3 years ago

actual problem is on first time focus on the grid we are not getting any callback from library. like if we go to some other view and then come back to this program grid the focus is there but we cannot get any callback

dzolnai commented 3 years ago

Isn't that because the grid is not showing any items yet because it is still loading? That might be your issue. You could check the load state, and if it is loaded, put focus on the grid. Until then, you can put an hidden view behind the grid and request focus on that.

psandroiddev commented 3 years ago

Data is present and the grid is loaded

dzolnai commented 3 years ago

When do you call requestFocus exactly? What is the trigger?

psandroiddev commented 3 years ago

at first when data is loaded. Then just navigating using dpad back & forth into the programguidegrid view

dzolnai commented 3 years ago

Yes, but how do you detect when data is loaded. You should not request immediately, because the RecyclerView needs to load its data, check for diffs, and create the views. Please try delaying the requestFocus with about 100-200ms, that should solve it.

dzolnai commented 3 years ago

Closing since no response. Feel free to reopen if you have further comments.