Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class BaseEpoxyHolder : EpoxyHolder() {
- lateinit var itemView: View
- final override fun bindView(view: View?) {
- this.itemView = view!!
- onBindView(itemView)
- }
- abstract fun onBindView(view: View)
- }
- fun <V : View> BaseEpoxyHolder.viewId(id: Int)
- : ReadOnlyProperty<BaseEpoxyHolder, V> = Lazy { _, _ ->
- this.itemView.findViewById(id) as V
- }
- private class Lazy<T, R>(private val initializer: (T, KProperty<*>) -> R) : ReadOnlyProperty<T, R> {
- private object EMPTY
- private var value: Any? = EMPTY
- override fun getValue(thisRef: T, property: KProperty<*>): R {
- if (value == EMPTY) {
- value = initializer(thisRef, property)
- }
- return value as R
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement