I am running into issues trying to take a function as a parameter in a binding adapter using Kotlin/Android databinding. This example code throws e: error: cannot generate view binders java.lang.StackOverflowError
when building with no other useful info in the log.
Here is my binding adapter:
@JvmStatic
@BindingAdapter("onDelayedClick")
fun onDelayedClick(view: View, function: () -> Unit) {
// TODO: Do something
}
XML:
<View
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:onDelayedClick="@{() -> viewModel.testFunction()}"/>
and method in my ViewModel:
fun testFunction() = Unit
I have been struggling with this for a bit now and nothing I've tried works, so any help is appreciated.