From 8a7936d6fa44863597a999b479bb05d8b96e81e2 Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Thu, 9 Oct 2025 02:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AC=E4=B9=A6=E9=97=AA?= =?UTF-8?q?=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kazusa/ui/book/audio/AudioPlayActivity.kt | 15 ++++++++------- app/src/main/res/layout/activity_audio_play.xml | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/ui/book/audio/AudioPlayActivity.kt b/app/src/main/java/io/legato/kazusa/ui/book/audio/AudioPlayActivity.kt index 4fba15bb3..f802b2679 100644 --- a/app/src/main/java/io/legato/kazusa/ui/book/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legato/kazusa/ui/book/audio/AudioPlayActivity.kt @@ -229,7 +229,6 @@ class AudioPlayActivity : // } // }) - // 替换原来的 SeekBar 监听器 binding.playerProgress.addOnChangeListener { _, value, fromUser -> if (fromUser) { binding.tvDurTime.text = progressTimeFormat.format(value.toLong()) @@ -648,14 +647,16 @@ class AudioPlayActivity : // binding.playerProgress.secondaryProgress = it // // } - observeEventSticky(EventBus.AUDIO_SIZE) { - binding.playerProgress.valueTo = maxOf(1f, it.toFloat()) - binding.tvAllTime.text = progressTimeFormat.format(it.toLong()) + observeEventSticky(EventBus.AUDIO_SIZE) { size -> + binding.playerProgress.valueTo = maxOf(1f, size.toFloat()) + binding.tvAllTime.text = progressTimeFormat.format(size.toLong()) } - observeEventSticky(EventBus.AUDIO_PROGRESS) { - if (!adjustProgress) binding.playerProgress.value = it.toFloat() - binding.tvDurTime.text = progressTimeFormat.format(it.toLong()) + observeEventSticky(EventBus.AUDIO_PROGRESS) { progress -> + val slider = binding.playerProgress + val safeValue = progress.toFloat().coerceIn(slider.valueFrom, slider.valueTo) + if (!adjustProgress) slider.value = safeValue + binding.tvDurTime.text = progressTimeFormat.format(progress.toLong()) } observeEventSticky(EventBus.AUDIO_BUFFER_PROGRESS) { diff --git a/app/src/main/res/layout/activity_audio_play.xml b/app/src/main/res/layout/activity_audio_play.xml index ccf2a8d76..d3fdc3252 100644 --- a/app/src/main/res/layout/activity_audio_play.xml +++ b/app/src/main/res/layout/activity_audio_play.xml @@ -163,7 +163,7 @@ android:layout_marginHorizontal="14dp" android:value="0" android:valueFrom="0" - android:valueTo="1" + android:valueTo="100000" app:tickColorInactive="@android:color/transparent" app:layout_constraintBottom_toTopOf="@id/tv_all_time" app:thumbElevation="0dp"