Skip to content

Commit

Permalink
removed Lifecycle-Watcher.kt: add-fragment-if-absent does not work co…
Browse files Browse the repository at this point in the history
…rrectly which leads to evil lifecycle bugs
  • Loading branch information
Miha-x64 committed Mar 14, 2020
1 parent 45d67fb commit 3dd5be1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 84 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.annotation.RequiresApi
import androidx.annotation.UiThread
import net.aquadc.properties.Property
import net.aquadc.properties.addUnconfinedChangeListener
import net.aquadc.properties.android.observeStartedIf
//import net.aquadc.properties.android.observeStartedIf


/**
Expand Down Expand Up @@ -65,18 +65,18 @@ fun <V : View, T> V.bindViewTo(source: Property<T>, destination: android.util.Pr
@JvmField protected val view: V,
@JvmField protected val property: Property<@UnsafeVariance T>
) : View.OnAttachStateChangeListener
, (Boolean) -> Unit // started state changed
// , (Boolean) -> Unit // started state changed
, (T, T) -> Unit, Runnable // value changed
{

@UiThread override fun onViewAttachedToWindow(v: View) {
view.context.observeStartedIf(true, this)
/*view.context.observeStartedIf(true, this)*/ invoke(true)
}
@UiThread override fun onViewDetachedFromWindow(v: View) {
view.context.observeStartedIf(false, this)
/*view.context.observeStartedIf(false, this)*/ invoke(false)
}

@UiThread override fun invoke(isStarted: Boolean) { // View is attached, Activity changes its Started state
@UiThread /*override*/ fun invoke(isStarted: Boolean) { // View is attached, let's think Activity is started
if (isStarted) {
// We're probably the first listener,
// subscription may trigger value computation.
Expand Down

0 comments on commit 3dd5be1

Please sign in to comment.