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() { fun makeAllPlaybacksIdle() {
listeners.keys.forEach { key -> listeners.keys.forEach { key ->
val currentPlaybackTime = getPlaybackTime(key) val currentPlaybackTime = getPlaybackTime(key)
@ -95,9 +99,9 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
fun getPlaybackTime(id: String): Int { fun getPlaybackTime(id: String): Int {
return when (val state = states[id]) { return when (val state = states[id]) {
is Listener.State.Playing -> state.playbackTime is Listener.State.Playing -> state.playbackTime
is Listener.State.Idle -> state.playbackTime is Listener.State.Idle -> state.playbackTime
else -> 0 else -> 0
} }
} }
@ -118,7 +122,7 @@ class VoiceMessagePlaybackTracker @Inject constructor() {
fun onUpdate(state: State) fun onUpdate(state: State)
sealed class 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 Playing(val playbackTime: Int) : State()
data class Recording(val amplitudeList: List<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) super.unbind(holder)
contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId) contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId)
contentDownloadStateTrackerBinder.unbind(mxcUrl) contentDownloadStateTrackerBinder.unbind(mxcUrl)
voiceMessagePlaybackTracker.unTrack(attributes.informationData.eventId)
} }
override fun getViewType() = STUB_ID override fun getViewType() = STUB_ID