Skip to content

Commit

Permalink
Make TextView type changeable in real time (Fix)!
Browse files Browse the repository at this point in the history
  • Loading branch information
slaviboy committed Apr 14, 2020
1 parent abd4cd8 commit 6a0e44e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions colorpicker/src/main/java/com/slaviboy/colorpicker/Updater.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ class Updater(
fun updateTextViewTag(textView: TextView, type: Int) {

if (textViews.containsKey(textView)) {

if (type == TYPE_HEX) {
// for hex limit to 7 digits
textView.filters = arrayOf<InputFilter>(LengthFilter(7))
} else if (type == TYPE_RGB || type == TYPE_RGBA || type == TYPE_HSV || type == TYPE_HSL || type == TYPE_CMYK) {
// multiple values expected
} else {
// for single integer values limit to 3 digits
textView.filters = arrayOf<InputFilter>(LengthFilter(3))
}

textView.isCursorVisible = false
textViews[textView] = type
updateTextView(textView)
}
Expand Down

0 comments on commit 6a0e44e

Please sign in to comment.