mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Make AudioMessagePlaybackTracker.Listener interface funny
This commit is contained in:
parent
226e2026a1
commit
6b57b1190c
4 changed files with 20 additions and 26 deletions
|
@ -148,7 +148,7 @@ class AudioMessagePlaybackTracker @Inject constructor() {
|
||||||
const val RECORDING_ID = "RECORDING_ID"
|
const val RECORDING_ID = "RECORDING_ID"
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Listener {
|
fun interface Listener {
|
||||||
|
|
||||||
fun onUpdate(state: State)
|
fun onUpdate(state: State)
|
||||||
|
|
||||||
|
|
|
@ -140,16 +140,14 @@ abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderStateBasedOnAudioPlayback(holder: Holder) {
|
private fun renderStateBasedOnAudioPlayback(holder: Holder) {
|
||||||
audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener {
|
audioMessagePlaybackTracker.track(attributes.informationData.eventId) { state ->
|
||||||
override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) {
|
when (state) {
|
||||||
when (state) {
|
is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder)
|
is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state)
|
is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state)
|
is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderIdleState(holder: Holder) {
|
private fun renderIdleState(holder: Holder) {
|
||||||
|
|
|
@ -116,14 +116,12 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageVoiceBroadcastItem
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
playbackTracker.track(voiceBroadcast.voiceBroadcastId, object : AudioMessagePlaybackTracker.Listener {
|
playbackTracker.track(voiceBroadcast.voiceBroadcastId) { playbackState ->
|
||||||
override fun onUpdate(state: State) {
|
renderBackwardForwardButtons(holder, playbackState)
|
||||||
renderBackwardForwardButtons(holder, state)
|
if (!isUserSeeking) {
|
||||||
if (!isUserSeeking) {
|
holder.seekBar.progress = playbackTracker.getPlaybackTime(voiceBroadcast.voiceBroadcastId)
|
||||||
holder.seekBar.progress = playbackTracker.getPlaybackTime(voiceBroadcast.voiceBroadcastId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderBackwardForwardButtons(holder: Holder, playbackState: State) {
|
private fun renderBackwardForwardButtons(holder: Holder, playbackState: State) {
|
||||||
|
|
|
@ -122,16 +122,14 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener {
|
audioMessagePlaybackTracker.track(attributes.informationData.eventId) { state ->
|
||||||
override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) {
|
when (state) {
|
||||||
when (state) {
|
is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder, waveformColorIdle, waveformColorPlayed)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder, waveformColorIdle, waveformColorPlayed)
|
is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state, waveformColorIdle, waveformColorPlayed)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state, waveformColorIdle, waveformColorPlayed)
|
is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state, waveformColorIdle, waveformColorPlayed)
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state, waveformColorIdle, waveformColorPlayed)
|
is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit
|
||||||
is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f)
|
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f)
|
||||||
|
|
Loading…
Reference in a new issue