2 Commits 9377c216b8 ... 8d5e20d338

Author SHA1 Message Date
  Wayne Huang 8d5e20d338 Merge branch '143-mediaboxseekbar-crash' into 'master' 4 years ago
  Wayne 762df62848 Fix: MediaBoxSeekBar crash issue 4 years ago

+ 5 - 3
src/main/java/com/kdanmobile/reader/screen/reader/mediabox/common/MediaBoxSeekBar.kt

@@ -3,11 +3,11 @@ package com.kdanmobile.reader.screen.reader.mediabox.common
 import android.content.Context
 import android.graphics.PorterDuff
 import android.os.Build
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.content.ContextCompat
 import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.widget.SeekBar
+import androidx.constraintlayout.widget.ConstraintLayout
+import androidx.core.content.ContextCompat
 import com.kdanmobile.reader.R
 import kotlinx.android.synthetic.main.view_media_box_seekbar.view.*
 
@@ -37,7 +37,9 @@ class MediaBoxSeekBar : ConstraintLayout {
 
     var currentValue = 0
         set(value) {
-            field = Math.max(Math.min(value, maxValue), minValue)
+            val v = value.coerceIn(minValue, maxValue)
+            if (field == v) return
+            field = v
             tv_mediaBoxSeekBar_value?.text = "${formatter.format(currentValue)}$unit"
             seekBar_mediaBoxSeekBar?.progress = field - minValue
         }