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

Run LeanbackHelper onPause() to refresh home screen #4347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hdweiss
Copy link

@hdweiss hdweiss commented Dec 27, 2024

Changes
Run LeanbackHelper onPause() to refresh home screen. When the app is paused, it is probably because the user navigated to the home screen.

Issues
#3139

@nielsvanvelzen
Copy link
Member

This is not a proper solution to the linked issue. The MainActivity will get paused a lot more often, like when playing a video or when opening the preferences. The worker code does quite a lot of API calls so we shouldn't spam it.

@hdweiss
Copy link
Author

hdweiss commented Dec 28, 2024

That is a good point. Is there any other hook we could use or is there a way to throttle the worker?

My only idea would be to move the worker call to onStop(), so that the home row either gets updated by the periodic worker within one hour or when the TV clears the app from memory. Would that be an acceptable solution?

@nielsvanvelzen
Copy link
Member

We could maybe add an additional function to update the "next up" row only once (video-)playback finishes. The other rows shouldn't change that often so I don't think anyone will notice if those update later.

@hdweiss
Copy link
Author

hdweiss commented Dec 29, 2024

According to the Android guidelines, the refresh for TV shows should happen when 1. "The user exits the app on Android TV." and 2. "The user pauses or stops playback for a piece of content for more than 5 minutes."

I have tried moving the worker call into the onStop() callback of the MainActivity, which would satisfy the first point. I have tested this and it is working perfectly on my TV.

For the second point, would this be done by listening on the PlaybackControllerNotifiable:onCompletion event?

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

Successfully merging this pull request may close these issues.

2 participants