Last active
November 27, 2019 20:33
-
-
Save Zhuinden/8b5ebd5121dc707753feb874099d6775 to your computer and use it in GitHub Desktop.
Anemic Repository 5
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 MyView(...): ... { | |
interface Listener { | |
fun onTextChanged(text: String) | |
fun onButtonPressed() | |
fun onCheckBoxTicked() | |
} | |
var listener: Listener? = null | |
// can make this a list if you want | |
override fun onFinishInflate() { | |
super.onFinishInflate() | |
button.onClick { | |
listener?.onButtonPressed() | |
} | |
editText.onTextChanged { text -> | |
listener?.onTextChanged(text) | |
} | |
checkBox.onCheckedChanged { checked -> | |
listener?.onCheckBoxTicked() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment