Skip to content
Permalink
e16dbd6923
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
35 lines (28 sloc) 923 Bytes
package com.gabrielfv.core.arch
import android.os.Parcelable
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
abstract class BindingView<B : ViewBinding, S : Parcelable>(
override val controller: Controller<S>
) : View<S>, Destroyable {
private var _binding: B? = null
val binding get() = _binding!!
abstract fun bind(inflater: LayoutInflater, container: ViewGroup?): B
abstract fun onNewState(state: S)
override fun inflate(inflater: LayoutInflater, root: ViewGroup?): android.view.View {
controller.registerDestroyable(this)
val binding = bind(inflater, root)
_binding = binding
onStart()
return binding.root
}
override fun updateState(state: S) {
if (_binding != null) {
onNewState(state)
}
}
override fun destroy() {
_binding = null
}
}