ananas/app
lsrom 308d97068f
Refactor playback code (#55)
* Refactor playback code

* Fix back state when playing media and rotating device

Problem was playerItems were re-emitted on fragment creation after config change. LiveData by design emit on every subscribe (observe) so to avoid that there are several possibilities.

1) easiest, observe playerItems not in onCreate but in playButton.clickListener. Stupid, since then we need to remember to only observe in this special place.

2) SingleLiveData - kind of hacky since LiveData were designed to behave this way so we don't want to go against their design.

3) Use Kotlin flow instead.

I chose the flow approach since it's Kotlin native and modern way to do things and behaves much more Rx-like. Since now we need to call collect instead of observe and launch in coroutine, I added utility method to make this easier. Also, in the future we might want to improve this further, either by coming up with new way entirely or by at least moving this to parent fragment from which all fragments that want to play media will inherit and thus making it easy to use and maintain.

Co-authored-by: Jarne Demeulemeester <32322857+jarnedemeulemeester@users.noreply.github.com>
2021-10-26 18:11:22 +02:00
..
libs Move libmpv lib out of seperate directory 2021-09-19 11:30:04 +02:00
src Refactor playback code (#55) 2021-10-26 18:11:22 +02:00
.gitignore Initial project 2021-05-29 10:52:44 +02:00
build.gradle.kts Update dependencies and improve server discovery 2021-10-23 17:39:46 +02:00
proguard-rules.pro Add mpvlib to proguard rules 2021-09-23 09:39:51 +02:00