Skip to content

Instantly share code, notes, and snippets.

@tsuharesu
Last active Jan 9, 2016
Embed
What would you like to do?
Kotlin ViewBinder for Android
/**
* View binder with nullable types support
*/
class ViewBinder<M>(val function: (M) -> Unit) : ReadWriteProperty<Any, M> {
private var mValue: M? = null
override fun getValue(thisRef: Any, property: KProperty<*>): M {
return mValue as M
}
override fun setValue(thisRef: Any, property: KProperty<*>, value: M) {
mValue = value
function(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment