Timeline: remove LifecycleOwner on EpoxyModel as it's not used (and takes some time uselessly)
This commit is contained in:
parent
31ba912d6e
commit
faebf95e1c
|
@ -30,24 +30,19 @@ import kotlinx.coroutines.cancelChildren
|
|||
/**
|
||||
* EpoxyModelWithHolder which can listen to visibility state change
|
||||
*/
|
||||
abstract class VectorEpoxyModel<H : VectorEpoxyHolder> : EpoxyModelWithHolder<H>(), LifecycleOwner {
|
||||
abstract class VectorEpoxyModel<H : VectorEpoxyHolder> : EpoxyModelWithHolder<H>(){
|
||||
|
||||
protected val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)
|
||||
|
||||
override fun getLifecycle() = lifecycleRegistry
|
||||
|
||||
private var onModelVisibilityStateChangedListener: OnVisibilityStateChangedListener? = null
|
||||
|
||||
@CallSuper
|
||||
override fun bind(holder: H) {
|
||||
super.bind(holder)
|
||||
lifecycleRegistry.currentState = Lifecycle.State.STARTED
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun unbind(holder: H) {
|
||||
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED
|
||||
coroutineScope.coroutineContext.cancelChildren()
|
||||
super.unbind(holder)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue