I've created a View and I encountered a problem with my interface for Buttons ClickListener. Interface looks like this
interface CustomButtonsClickListener : () -> Unit {
fun onPlusClick(view: View, button: ImageButton)
fun onMinusClick(view: View, button: ImageButton)
}
It is implemented by the method:
fun setCustomButtonsClickListeners(clickListener: CustomButtonsClickListener) {
binding.addButton.setOnClickListener {
clickListener.onPlusClick(this, binding.addButton)
}
binding.minusButton.setOnClickListener {
clickListener.onMinusClick(this, binding.minusButton)
}
}
This is how it look like "outside"
view.setCustomButtonsClickListeners(object : CustomButtonsClickListener {
override fun onPlusClick(view: View, button: ImageButton) {
}
override fun onMinusClick(view: View, button: ImageButton) {
}
})
The Problem:
I am getting error on object
saying:
Object is not abstract and does not implement abstract member public abstract fun invoke()...
What is the method invoke()
and how should I implement it? I would rather do it inside the View class so I don't have to do it while using the View somewhere in the app.