Sam Stone
03/09/2023, 12:05 AMandroid.text.TextWatcher
as an example. I am not interested in beforeTextChanged()
and onTextChanged()
, only afterTextChanged()
. In a big action listener class (with many listener functions), this can be many functions that need to be implemented as override fun foo() {}
. It would be convenient if I didn’t have to specify that the first two functions don’t do anything:
object : TextWatcher {
override fun beforeTextChanged(...) {}
override fun onTextChanged(...) {}
override fun afterTextChanged(...) {
...
}
}
Paul Griffith
03/09/2023, 12:20 AMjbnizet
03/09/2023, 4:44 PMobject DoNothingTextWatcher : TextWatcher {
override fun beforeTextChanged() = Unit
override fun onTextChanged() = Unit
override fun afterTextChanged() = Unit
}
fun main() {
val myWatcher = object : TextWatcher by DoNothingTextWatcher {
override fun afterTextChanged() {
println("hello")
}
}
myWatcher.beforeTextChanged()
myWatcher.onTextChanged()
myWatcher.afterTextChanged()
}
Sam Stone
03/09/2023, 7:16 PMjbnizet
03/09/2023, 8:22 PMSam Stone
03/09/2023, 8:26 PMjbnizet
03/09/2023, 8:30 PMPaul Griffith
03/09/2023, 9:07 PMSam Stone
03/09/2023, 10:41 PM