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:
OxygenCobalt
2022-01-07 14:10:45 -07:00
parent 9a7571a59a
commit 70ac37ca8a
@@ -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()
}