Fix possible crash rendering playback time

https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/1087

Change-Id: I688e93637a0b0c42907b980cb619f5cb6c991c50
This commit is contained in:
SpiritCroc 2023-08-02 20:38:38 +02:00
parent 1bc97e0aba
commit f605667a97

View file

@ -190,7 +190,7 @@ abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>() {
private fun getPlaybackTimeContentDescription(context: Context, time: Int): String {
val formattedPlaybackTime = formatPlaybackTime(time)
val (minutes, seconds) = formattedPlaybackTime.split(":").map { it.toIntOrNull() ?: 0 }
val (minutes, seconds) = formattedPlaybackTime.split(":").map { it.toIntOrNull() ?: 0 }.let { if (it.size > 1) it else listOf(0) + it }
return context.getString(R.string.a11y_audio_playback_duration, minutes, seconds)
}