I\'m converting a project in Java to Kotlin and I\'m surprise that interface made the code heavier in Kotlin than in Java.
Example: I want to set t
You use Java style while use Kotlin =)
If you really want to use OnBackPressedListener you can just wrap it in inline function, like:
inline fun backPress(crossinline action:()->Unit):OnBackPressedListener {
return object: OnBackPressedListener {
override fun onBackPressed() {
action()
}
}
}
And then just set listener
activity.setOnBackPressed(backPress {
/* Do something */
})