Fix numberpicker set limit to max or min

This commit is contained in:
Andries Smit 2022-01-27 09:40:45 +01:00
parent 8f7b178c04
commit 00d30c23fa

View file

@ -192,6 +192,14 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
set(value) {
if (watcher != null) editText?.removeTextChangedListener(watcher)
currentValue = value
if (currentValue > maxValue) {
currentValue = maxValue
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
}
if (currentValue < minValue) {
currentValue = minValue
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
}
callValueChangedListener()
updateEditText()
if (watcher != null) editText?.addTextChangedListener(watcher)