playback: fix seekbar crash
Fix an edge case where if the total duration ends up being zero, the app will end up crashing at the playback screen. Thank SeekBar for deciding that it's perfectly okay to crash instead of decay gracefully when valueTo is 0.
This commit is contained in:
parent
9a7571a59a
commit
70ac37ca8a
1 changed files with 2 additions and 1 deletions
|
@ -29,6 +29,7 @@ import org.oxycblt.auxio.databinding.ViewSeekBarBinding
|
|||
import org.oxycblt.auxio.music.toDuration
|
||||
import org.oxycblt.auxio.util.inflater
|
||||
import org.oxycblt.auxio.util.resolveAttr
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* A custom view that bundles together a seekbar with a current duration and a total duration.
|
||||
|
@ -67,7 +68,7 @@ class PlaybackSeekBar @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun setDuration(seconds: Long) {
|
||||
binding.seekBar.valueTo = seconds.toFloat()
|
||||
binding.seekBar.valueTo = max(seconds.toFloat(), 1f)
|
||||
binding.playbackSongDuration.text = seconds.toDuration()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue