|
@@ -6,9 +6,9 @@ import android.util.AttributeSet
|
|
|
import android.view.LayoutInflater
|
|
|
import android.widget.SeekBar
|
|
|
import com.kdanmobile.reader.R
|
|
|
-import kotlinx.android.synthetic.main.view_viewer_edit_item_seekbar.view.*
|
|
|
+import kotlinx.android.synthetic.main.view_media_box_seekbar.view.*
|
|
|
|
|
|
-class TextSeekBar : ConstraintLayout {
|
|
|
+class MediaBoxSeekBar : ConstraintLayout {
|
|
|
|
|
|
private var title = ""
|
|
|
private var unit = ""
|
|
@@ -25,7 +25,7 @@ class TextSeekBar : ConstraintLayout {
|
|
|
var formatter = defaultFormatter
|
|
|
set(value) {
|
|
|
field = value
|
|
|
- tv_seekBarValue?.text = "${formatter.format(currentValue)}$unit"
|
|
|
+ tv_mediaBoxSeekBar_value?.text = "${formatter.format(currentValue)}$unit"
|
|
|
}
|
|
|
|
|
|
interface SeekBarFormatter {
|
|
@@ -35,8 +35,8 @@ class TextSeekBar : ConstraintLayout {
|
|
|
var currentValue = 0
|
|
|
set(value) {
|
|
|
field = Math.max(Math.min(value, maxValue), minValue)
|
|
|
- tv_seekBarValue?.text = "${formatter.format(currentValue)}$unit"
|
|
|
- seekBar?.progress = field - minValue
|
|
|
+ tv_mediaBoxSeekBar_value?.text = "${formatter.format(currentValue)}$unit"
|
|
|
+ seekBar_mediaBoxSeekBar?.progress = field - minValue
|
|
|
}
|
|
|
var onSeekBarChangeListener: SeekBar.OnSeekBarChangeListener? = null
|
|
|
|
|
@@ -55,23 +55,23 @@ class TextSeekBar : ConstraintLayout {
|
|
|
}
|
|
|
|
|
|
private fun initAttr(attributeSet: AttributeSet) {
|
|
|
- val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.TextSeekBar, 0, 0)
|
|
|
- title = typedArray.getString(R.styleable.TextSeekBar_title) ?: ""
|
|
|
- unit = typedArray.getString(R.styleable.TextSeekBar_unit) ?: ""
|
|
|
- maxValue = typedArray.getInteger(R.styleable.TextSeekBar_maxValue, 100)
|
|
|
- minValue = typedArray.getInteger(R.styleable.TextSeekBar_minValue, 0)
|
|
|
+ val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.MediaBoxSeekBar, 0, 0)
|
|
|
+ title = typedArray.getString(R.styleable.MediaBoxSeekBar_title) ?: ""
|
|
|
+ unit = typedArray.getString(R.styleable.MediaBoxSeekBar_unit) ?: ""
|
|
|
+ maxValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_maxValue, 100)
|
|
|
+ minValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_minValue, 0)
|
|
|
if (maxValue < minValue)
|
|
|
maxValue = minValue
|
|
|
- initValue = typedArray.getInteger(R.styleable.TextSeekBar_initValue, 0)
|
|
|
+ initValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_initValue, 0)
|
|
|
initValue = Math.max(Math.min(initValue, maxValue), minValue)
|
|
|
}
|
|
|
|
|
|
private fun initView() {
|
|
|
- LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_item_seekbar, this)
|
|
|
+ LayoutInflater.from(context).inflate(R.layout.view_media_box_seekbar, this)
|
|
|
|
|
|
- tv_seekBarTitle.text = title
|
|
|
- seekBar.max = maxValue - minValue
|
|
|
- seekBar.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
|
|
|
+ tv_mediaBoxSeekBar_title.text = title
|
|
|
+ seekBar_mediaBoxSeekBar.max = maxValue - minValue
|
|
|
+ seekBar_mediaBoxSeekBar.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
|
|
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
|
|
currentValue = progress + minValue
|
|
|
onSeekBarChangeListener?.onProgressChanged(seekBar, currentValue, fromUser)
|