Fixes bugs related to audio message duration being set incorrectly between activity states

This commit is contained in:
ericdecanini 2022-03-29 17:40:00 +02:00
parent cc5e8f35a7
commit 6adf4878f7
2 changed files with 6 additions and 3 deletions

View File

@ -900,6 +900,7 @@ class TimelineFragment @Inject constructor(
} }
override fun onDestroyView() { override fun onDestroyView() {
audioMessagePlaybackTracker.makeAllPlaybacksIdle()
lazyLoadedViews.unBind() lazyLoadedViews.unBind()
timelineEventController.callback = null timelineEventController.callback = null
timelineEventController.removeModelBuildListener(modelBuildListener) timelineEventController.removeModelBuildListener(modelBuildListener)

View File

@ -93,10 +93,12 @@ class AudioMessagePlaybackTracker @Inject constructor() {
} }
fun pausePlayback(id: String) { fun pausePlayback(id: String) {
if (getPlaybackState(id) is Listener.State.Playing) {
val currentPlaybackTime = getPlaybackTime(id) val currentPlaybackTime = getPlaybackTime(id)
val currentPercentage = getPercentage(id) val currentPercentage = getPercentage(id)
setState(id, Listener.State.Paused(currentPlaybackTime, currentPercentage)) setState(id, Listener.State.Paused(currentPlaybackTime, currentPercentage))
} }
}
fun stopPlayback(id: String) { fun stopPlayback(id: String) {
setState(id, Listener.State.Idle) setState(id, Listener.State.Idle)