This commit is contained in:
Benoit Marty 2021-07-13 15:22:45 +02:00 committed by Benoit Marty
parent bf14fa90a2
commit 7937c9945b
2 changed files with 9 additions and 4 deletions

View File

@ -37,6 +37,10 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
}
}
fun unTrack(id: String) {
listeners.remove(id)
}
fun makeAllPlaybacksIdle() {
listeners.keys.forEach { key ->
val currentPlaybackTime = getPlaybackTime(key)
@ -95,9 +99,9 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
fun getPlaybackTime(id: String): Int {
return when (val state = states[id]) {
is Listener.State.Playing -> state.playbackTime
is Listener.State.Idle -> state.playbackTime
else -> 0
is Listener.State.Playing -> state.playbackTime
is Listener.State.Idle -> state.playbackTime
else -> 0
}
}
@ -118,7 +122,7 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
fun onUpdate(state: State)
sealed class State {
data class Idle(val playbackTime: Int): State()
data class Idle(val playbackTime: Int) : State()
data class Playing(val playbackTime: Int) : State()
data class Recording(val amplitudeList: List<Int>) : State()
}

View File

@ -115,6 +115,7 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
super.unbind(holder)
contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId)
contentDownloadStateTrackerBinder.unbind(mxcUrl)
voiceMessagePlaybackTracker.unTrack(attributes.informationData.eventId)
}
override fun getViewType() = STUB_ID