egeniq / android-tv-program-guide

Android TV Program Guide
Apache License 2.0
162 stars 63 forks source link

Focus Loss while updating list doing pagination #72

Open Durgesh-1992 opened 4 hours ago

Durgesh-1992 commented 4 hours ago

Thanks for having patience with my query and helping me out. I have another query,When we do horizontal scroll and load future or past data then focus loss is seen. I checked on which view component using logging activity.currentFocus it focus is on program grid item but it doenst take any dpad event. the only recovery to this focus lost is focus on otherview component like filter. Can you pls guide me where to look in the code for this issue or what can be the reason for this.

dzolnai commented 4 hours ago

Hello, this part of the code might be your issue:

https://github.com/egeniq/android-tv-program-guide/blob/0dbc943b14700de26a5ccd4d00eed885d8f90734/library/src/main/java/com/egeniq/androidtvprogramguide/ProgramGuideFragment.kt#L675

The problem is, when loading data, the grid should never be in focus, because it could lead to weird jumping and incorrect scroll status. I think what you need to do, is put the focus back on the grid once the data is loaded, probably on the item focused before?

Durgesh-1992 commented 4 minutes ago

onChildDetachedFromWindow is getting called I checked in the logs which remove the currently focused child element and again when focus appear it appears on other child not on previous focused child.

dzolnai commented 2 minutes ago

You could try to remember the previously focused child, and calling focus on it manually when the loading is done?