egeniq / android-tv-program-guide

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

Focus Loss while updating list doing pagination #72

Open Durgesh-1992 opened 1 month ago

Durgesh-1992 commented 1 month 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 1 month 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 1 month 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 1 month ago

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

Durgesh-1992 commented 1 month ago

yeah I have already added that code to request focus but sometime it doesn't works. Also in my case if there are multiple set of pagination data is getting loaded for past days then this issue is frequent but it rarely happens when data is getting loaded for future day or date time after current viewport time.