Just keep function on the top level, no class or companion object needed, it will work since top-level functions in Kotlin translated to static member functions of Class named as FileNameKt unless overridden by @file:JvmName annotation
@BindingAdapter("imageUrl")
fun loadImage(view: ImageView, url:String) { ... }
One more option is to annotate Extension Function as @BindingAdapter, it will work since in bytecode signature will exactly match signature expected by DataBindings(generated method will still accept an object of the extended class as the first argument), the function should remain top level as well
@BindingAdapter("imageUrl")
fun ImageView.loadImage(url:String) { ... }
One more option is to combine BindingAdapter with the extension property like following:
@set:BindingAdapter("visible")
var View.visible
get() = visibility == VISIBLE
set(value) {
visibility = if (value) VISIBLE else GONE
}