fix NumberPicker in automation

This commit is contained in:
Milos Kozak 2021-10-29 17:35:40 +02:00
parent 7365986286
commit eed8aa8441
6 changed files with 24 additions and 26 deletions

View file

@ -28,10 +28,10 @@ class InputBg(profileFunction: ProfileFunction) : Element() {
override fun addToLayout(root: LinearLayout) {
root.addView(
NumberPicker(root.context, null).apply {
setParams(value, minValue, maxValue, step, decimalFormat, false, root.findViewById(R.id.ok))
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
NumberPicker(root.context, null).also {
it.setParams(value, minValue, maxValue, step, decimalFormat, false, root.findViewById(R.id.ok))
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
})
}

View file

@ -81,10 +81,10 @@ class InputDelta(private val resourceHelper: ResourceHelper) : Element() {
gravity = Gravity.CENTER_HORIZONTAL
})
root.addView(
NumberPicker(root.context, null).apply {
setParams(value, minValue, maxValue, step, decimalFormat, true, null, null)
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
NumberPicker(root.context, null).also {
it.setParams(value, minValue, maxValue, step, decimalFormat, true, null, null)
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
})
}
}

View file

@ -32,10 +32,10 @@ class InputDouble() : Element() {
}
override fun addToLayout(root: LinearLayout) {
numberPicker = NumberPicker(root.context, null).apply {
setParams(value, minValue, maxValue, step, decimalFormat, true, root.findViewById(R.id.ok))
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
numberPicker = NumberPicker(root.context, null).also {
it.setParams(value, minValue, maxValue, step, decimalFormat, true, root.findViewById(R.id.ok))
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
}
root.addView(numberPicker)
}

View file

@ -16,11 +16,10 @@ class InputInsulin() : Element() {
override fun addToLayout(root: LinearLayout) {
root.addView(
NumberPicker(root.context, null).apply {
setParams(0.0, -20.0, 20.0, 0.1, DecimalFormat("0.0"), true, root.findViewById(R.id.ok))
value = value
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
NumberPicker(root.context, null).also {
it.setParams(value, -20.0, 20.0, 0.1, DecimalFormat("0.0"), true, root.findViewById(R.id.ok))
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
})
}
}

View file

@ -16,11 +16,10 @@ class InputPercent() : Element() {
override fun addToLayout(root: LinearLayout) {
root.addView(
NumberPicker(root.context, null).apply {
setParams(100.0, MIN, MAX, 5.0, DecimalFormat("0"), true, root.findViewById(R.id.ok))
value = value
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
NumberPicker(root.context, null).also {
it.setParams(value, MIN, MAX, 5.0, DecimalFormat("0"), true, root.findViewById(R.id.ok))
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
})
}

View file

@ -41,10 +41,10 @@ class InputTempTarget(profileFunction: ProfileFunction) : Element() {
decimalFormat = DecimalFormat("0")
}
root.addView(
NumberPicker(root.context, null).apply {
setParams(value, minValue, maxValue, step, decimalFormat, true, root.findViewById(R.id.ok))
setOnValueChangedListener { value: Double -> this.value = value }
gravity = Gravity.CENTER_HORIZONTAL
NumberPicker(root.context, null).also {
it.setParams(value, minValue, maxValue, step, decimalFormat, true, root.findViewById(R.id.ok))
it.setOnValueChangedListener { v: Double -> value = v }
it.gravity = Gravity.CENTER_HORIZONTAL
})
}