NumberPicker lints
This commit is contained in:
parent
090994ab51
commit
ae466e51d0
|
@ -113,9 +113,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
if (focused) currentValue = SafeParse.stringToDouble(editText?.text.toString())
|
if (focused) currentValue = SafeParse.stringToDouble(editText?.text.toString())
|
||||||
callValueChangedListener()
|
callValueChangedListener()
|
||||||
if (okButton != null) {
|
okButton?.visibility = if (currentValue > maxValue || currentValue < minValue) INVISIBLE else VISIBLE
|
||||||
if (currentValue > maxValue || currentValue < minValue) okButton!!.visibility = INVISIBLE else okButton!!.visibility = VISIBLE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
editText?.setOnFocusChangeListener { _: View?, hasFocus: Boolean ->
|
editText?.setOnFocusChangeListener { _: View?, hasFocus: Boolean ->
|
||||||
|
@ -143,13 +141,13 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
||||||
currentValue = maxValue
|
currentValue = maxValue
|
||||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||||
updateEditText()
|
updateEditText()
|
||||||
if (okButton != null) okButton?.visibility = VISIBLE
|
okButton?.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
if (currentValue < minValue) {
|
if (currentValue < minValue) {
|
||||||
currentValue = minValue
|
currentValue = minValue
|
||||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||||
updateEditText()
|
updateEditText()
|
||||||
if (okButton != null) okButton?.visibility = VISIBLE
|
okButton?.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +227,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callValueChangedListener() {
|
private fun callValueChangedListener() {
|
||||||
if (mOnValueChangedListener != null) mOnValueChangedListener?.onValueChanged(currentValue)
|
mOnValueChangedListener?.onValueChanged(currentValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startUpdating(inc: Boolean) {
|
private fun startUpdating(inc: Boolean) {
|
||||||
|
@ -245,11 +243,9 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopUpdating() {
|
private fun stopUpdating() {
|
||||||
if (mUpdater != null) {
|
|
||||||
mUpdater?.shutdownNow()
|
mUpdater?.shutdownNow()
|
||||||
mUpdater = null
|
mUpdater = null
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
if (mUpdater == null) {
|
if (mUpdater == null) {
|
||||||
|
|
Loading…
Reference in a new issue