I would like to create a CountdownTimer which will trigger events that will update the UI (trigger popup, start an animation, etc.).
I wonder how to do this clean, here are my hypothesis and why :
- A separate component
EventCountdownTimer. I could then benefit the use ofLifecycleObserver, but I wonder how to communicate the information back to the activity (I tried extendingCountdownTimerand using it in the activity but I have an error and can't get it to compile) - In the
Activityitself, it's the simplest but I'm not sure it belongs there as it isn't a UI component and I can't benefit theLifecycleObserver - In the
ViewModel. I thought as it's activity related and theCountdownTimeris kinda logic data, it should go in here, but that means also watching the lifecycle of the activity, and holding anyActivityrelated field withinViewModelis bad practice.
What's the best option according to you? And why?