Created
November 3, 2018 05:02
-
-
Save whalemare/394d1400c0298d56c097575c4b5fee1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun TextView.onTextChanged(handler: (text: CharSequence) -> Unit): TextWatcher { | |
val watcher = object : TextWatcher { | |
override fun afterTextChanged(editable: Editable?) { | |
} | |
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
} | |
override fun onTextChanged(text: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
(text ?: "").let(handler::invoke) | |
} | |
} | |
addTextChangedListener(watcher) | |
return watcher | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment