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) { override fun addToLayout(root: LinearLayout) {
root.addView( root.addView(
NumberPicker(root.context, null).apply { NumberPicker(root.context, null).also {
setParams(value, minValue, maxValue, step, decimalFormat, false, root.findViewById(R.id.ok)) it.setParams(value, minValue, maxValue, step, decimalFormat, false, root.findViewById(R.id.ok))
setOnValueChangedListener { value: Double -> this.value = value } it.setOnValueChangedListener { v: Double -> value = v }
gravity = Gravity.CENTER_HORIZONTAL it.gravity = Gravity.CENTER_HORIZONTAL
}) })
} }

View file

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

View file

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

View file

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

View file

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

View file

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