Merge pull request #1233 from Andries-Smit/fix/numberpicker-set-limit

Fix/number picker set limit
This commit is contained in:
Milos Kozak 2022-01-29 19:06:18 +01:00 committed by GitHub
commit ecefcdf9c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -192,6 +192,14 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
set(value) { set(value) {
if (watcher != null) editText?.removeTextChangedListener(watcher) if (watcher != null) editText?.removeTextChangedListener(watcher)
currentValue = value 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() callValueChangedListener()
updateEditText() updateEditText()
if (watcher != null) editText?.addTextChangedListener(watcher) if (watcher != null) editText?.addTextChangedListener(watcher)