Created
August 30, 2020 06:04
-
-
Save ananth10/b78d7753ff2ef59edb481ff90d1af2f3 to your computer and use it in GitHub Desktop.
This is common TextWatcher for EditText component to avoid boiler plate code!!
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
class CommonTextWatcher( | |
private val beforeChanged:((CharSequence?,Int,Int,Int)->Unit)={_,_,_,_->}, | |
private val afterChanged:((Editable?)->Unit)={}, | |
private val onChanged:(CharSequence?,Int,Int,Int)->Unit | |
):TextWatcher { | |
override fun afterTextChanged(p0: Editable?) { | |
afterChanged(p0) | |
} | |
override fun beforeTextChanged(char: CharSequence?, start: Int, count: Int, after: Int) { | |
beforeChanged(char,start,count,after) | |
} | |
override fun onTextChanged(char: CharSequence?, start: Int, before: Int, count: Int) { | |
onChanged(char,start,before,count) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment