Sam Stone
03/06/2023, 12:09 AMandroid.text.TextWatcher
. I am not interested in beforeTextChanged()
and onTextChanged()
, only afterTextChanged()
. Should the compiler assume (or can I inform it) that I will implement it like this?
object : TextWatcher {
override fun beforeTextChanged(...) {}
override fun onTextChanged(...) {}
override fun afterTextChanged(...) {
...
}
}
Loney Chou
03/06/2023, 12:23 AMSam Stone
03/06/2023, 12:27 AMLoney Chou
03/06/2023, 12:31 AMRuckus
03/06/2023, 4:07 PMSam Stone
03/06/2023, 7:00 PMRuckus
03/06/2023, 8:15 PMthe owner of the interface specify that the compiler should generate default implementations if the client doesn’t need the unimplemented functionsThey can, by including a body in the interface.
interface TextWatcher {
fun beforeTextChanged(...) { /* Default do nothing implementation */ }
...
}
Is this not what you meant?Loney Chou
03/06/2023, 11:58 PMYoussef Shoaib [MOD]
03/07/2023, 5:18 AMSam Stone
03/09/2023, 12:02 AMYoussef Shoaib [MOD]
03/25/2023, 5:31 PMinterface TextWatcherBase: TextWatcher {
override fun beforeTextChanged(...) {}
override fun onTextChanged(...) {}
override fun afterTextChanged(...) {}
}
and you can inherit from it instead of TestWatcher
.