playback: fix slider crash
Fix crashes occuring from -1 positions causing Slider to error out. This is just fixed by band-aiding the UI, since I seemingly cannot control these from the backend.
This commit is contained in:
parent
c9422b7f9d
commit
dffa3dc34e
2 changed files with 6 additions and 4 deletions
|
@ -69,15 +69,17 @@ constructor(
|
|||
var positionDs: Long
|
||||
get() = binding.seekBarSlider.value.toLong()
|
||||
set(value) {
|
||||
val sanitized = max(value, 0)
|
||||
|
||||
// Sanity check: Ensure that this value is within the duration and will not crash
|
||||
// the app, and that the user is not currently seeking (which would cause the SeekBar
|
||||
// to jump around).
|
||||
if (value <= durationDs && !isActivated) {
|
||||
binding.seekBarSlider.value = value.toFloat()
|
||||
if (sanitized <= durationDs && !isActivated) {
|
||||
binding.seekBarSlider.value = sanitized.toFloat()
|
||||
|
||||
// We would want to keep this in the callback, but the callback only fires when
|
||||
// a value changes completely, and sometimes that does not happen with this view.
|
||||
binding.seekBarPosition.text = value.formatDurationDs(true)
|
||||
binding.seekBarPosition.text = sanitized.formatDurationDs(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.4.0-alpha10'
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
||||
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.6.1"
|
||||
|
|
Loading…
Reference in a new issue