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
|
var positionDs: Long
|
||||||
get() = binding.seekBarSlider.value.toLong()
|
get() = binding.seekBarSlider.value.toLong()
|
||||||
set(value) {
|
set(value) {
|
||||||
|
val sanitized = max(value, 0)
|
||||||
|
|
||||||
// Sanity check: Ensure that this value is within the duration and will not crash
|
// 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
|
// the app, and that the user is not currently seeking (which would cause the SeekBar
|
||||||
// to jump around).
|
// to jump around).
|
||||||
if (value <= durationDs && !isActivated) {
|
if (sanitized <= durationDs && !isActivated) {
|
||||||
binding.seekBarSlider.value = value.toFloat()
|
binding.seekBarSlider.value = sanitized.toFloat()
|
||||||
|
|
||||||
// We would want to keep this in the callback, but the callback only fires when
|
// 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.
|
// 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 {
|
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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
||||||
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.6.1"
|
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.6.1"
|
||||||
|
|
Loading…
Reference in a new issue