修复听书闪退问题
This commit is contained in:
2 files changed
+9
-8
No files matched your search
@@ -229,7 +229,6 @@ class AudioPlayActivity :
|
|||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
// 替换原来的 SeekBar 监听器
|
|
||||||
binding.playerProgress.addOnChangeListener { _, value, fromUser ->
|
binding.playerProgress.addOnChangeListener { _, value, fromUser ->
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
binding.tvDurTime.text = progressTimeFormat.format(value.toLong())
|
binding.tvDurTime.text = progressTimeFormat.format(value.toLong())
|
||||||
@@ -648,14 +647,16 @@ class AudioPlayActivity :
|
|||||||
// binding.playerProgress.secondaryProgress = it
|
// binding.playerProgress.secondaryProgress = it
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
observeEventSticky<Int>(EventBus.AUDIO_SIZE) {
|
observeEventSticky<Int>(EventBus.AUDIO_SIZE) { size ->
|
||||||
binding.playerProgress.valueTo = maxOf(1f, it.toFloat())
|
binding.playerProgress.valueTo = maxOf(1f, size.toFloat())
|
||||||
binding.tvAllTime.text = progressTimeFormat.format(it.toLong())
|
binding.tvAllTime.text = progressTimeFormat.format(size.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
observeEventSticky<Int>(EventBus.AUDIO_PROGRESS) {
|
observeEventSticky<Int>(EventBus.AUDIO_PROGRESS) { progress ->
|
||||||
if (!adjustProgress) binding.playerProgress.value = it.toFloat()
|
val slider = binding.playerProgress
|
||||||
binding.tvDurTime.text = progressTimeFormat.format(it.toLong())
|
val safeValue = progress.toFloat().coerceIn(slider.valueFrom, slider.valueTo)
|
||||||
|
if (!adjustProgress) slider.value = safeValue
|
||||||
|
binding.tvDurTime.text = progressTimeFormat.format(progress.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
observeEventSticky<Int>(EventBus.AUDIO_BUFFER_PROGRESS) {
|
observeEventSticky<Int>(EventBus.AUDIO_BUFFER_PROGRESS) {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
android:layout_marginHorizontal="14dp"
|
android:layout_marginHorizontal="14dp"
|
||||||
android:value="0"
|
android:value="0"
|
||||||
android:valueFrom="0"
|
android:valueFrom="0"
|
||||||
android:valueTo="1"
|
android:valueTo="100000"
|
||||||
app:tickColorInactive="@android:color/transparent"
|
app:tickColorInactive="@android:color/transparent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/tv_all_time"
|
app:layout_constraintBottom_toTopOf="@id/tv_all_time"
|
||||||
app:thumbElevation="0dp"
|
app:thumbElevation="0dp"
|
||||||
|
|||||||
Reference in new issue
Block a user