33 lines
988 B
Kotlin
33 lines
988 B
Kotlin
package com.yunbao.faceunity.utils
|
|
|
|
import android.view.View
|
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar
|
|
|
|
class SeekBarUtils {
|
|
companion object {
|
|
/**
|
|
* 设置滚动条数值
|
|
* @param value Double 结果值
|
|
* @param stand Double 标准值
|
|
* @param range Double 范围区间
|
|
*/
|
|
fun seekToSeekBar(bar: DiscreteSeekBar, value: Double, stand: Double, range: Double) {
|
|
if (stand == 0.5) {
|
|
bar.min = -50
|
|
bar.max = 50
|
|
bar.progress = (value * 100 / range - 50).toInt()
|
|
} else {
|
|
bar.min = 0
|
|
bar.max = 100
|
|
bar.progress = (value * 100 / range).toInt()
|
|
}
|
|
bar.visibility = View.VISIBLE
|
|
}
|
|
fun seekToValue(range:Double,value:Int,seekBarMin:Int):Double{
|
|
val valueF: Double = 1.0 * (value - seekBarMin) / 100
|
|
return range*valueF;
|
|
}
|
|
}
|
|
|
|
|
|
} |