mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Cleanup
This commit is contained in:
parent
bff2c6ea93
commit
6283846108
1 changed files with 9 additions and 15 deletions
|
@ -206,29 +206,23 @@ class VoiceMessageHelper @Inject constructor(
|
||||||
playbackTimer = CountUpTimer().apply {
|
playbackTimer = CountUpTimer().apply {
|
||||||
tickListener = object : CountUpTimer.TickListener {
|
tickListener = object : CountUpTimer.TickListener {
|
||||||
override fun onTick(milliseconds: Long) {
|
override fun onTick(milliseconds: Long) {
|
||||||
onPlaybackTimerTick(id, false)
|
onPlaybackTimerTick(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resume()
|
resume()
|
||||||
}
|
}
|
||||||
onPlaybackTimerTick(id, true)
|
onPlaybackTimerTick(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onPlaybackTimerTick(id: String, firstCall: Boolean) {
|
private fun onPlaybackTimerTick(id: String) {
|
||||||
when {
|
if (mediaPlayer?.isPlaying.orFalse()) {
|
||||||
firstCall -> {
|
|
||||||
playbackTracker.updateCurrentPlaybackTime(id, 0)
|
|
||||||
}
|
|
||||||
mediaPlayer?.isPlaying.orFalse() -> {
|
|
||||||
val currentPosition = mediaPlayer?.currentPosition ?: 0
|
val currentPosition = mediaPlayer?.currentPosition ?: 0
|
||||||
playbackTracker.updateCurrentPlaybackTime(id, currentPosition)
|
playbackTracker.updateCurrentPlaybackTime(id, currentPosition)
|
||||||
}
|
} else {
|
||||||
else -> {
|
|
||||||
playbackTracker.stopPlayback(id)
|
playbackTracker.stopPlayback(id)
|
||||||
stopPlaybackTimer()
|
stopPlaybackTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun stopPlaybackTimer() {
|
private fun stopPlaybackTimer() {
|
||||||
playbackTimer?.stop()
|
playbackTimer?.stop()
|
||||||
|
|
Loading…
Reference in a new issue