From dffa3dc34e0f299ff1262e51cc726b0ffd9da355 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Mon, 14 Nov 2022 19:41:23 -0700 Subject: [PATCH] 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. --- .../main/java/org/oxycblt/auxio/playback/StyledSeekBar.kt | 8 +++++--- build.gradle | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/StyledSeekBar.kt b/app/src/main/java/org/oxycblt/auxio/playback/StyledSeekBar.kt index 657c120d0..6bb64fd76 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/StyledSeekBar.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/StyledSeekBar.kt @@ -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) } } diff --git a/build.gradle b/build.gradle index 4699d5121..411cc64ab 100644 --- a/build.gradle +++ b/build.gradle @@ -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"