Make sure simple task delivers

pull/160/head
M66B 6 years ago
parent 0affd9e1f3
commit 3b51d9ce64

@ -129,21 +129,20 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
cleanup(context); cleanup(context);
} else } else
owner.getLifecycle().addObserver(new LifecycleObserver() { owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_START) @OnLifecycleEvent(Lifecycle.Event.ON_ANY)
public void onStart() { public void onAny() {
// Deferred delivery Lifecycle.State state = owner.getLifecycle().getCurrentState();
Log.i("Deferred delivery task " + name); if (state.equals(Lifecycle.State.DESTROYED)) {
Log.i("Destroyed task " + name);
owner.getLifecycle().removeObserver(this); owner.getLifecycle().removeObserver(this);
deliver();
cleanup(context); cleanup(context);
} } else if (state.isAtLeast(Lifecycle.State.STARTED)) {
Log.i("Deferred delivery task " + name);
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
// No delivery
Log.i("Destroyed task " + name);
owner.getLifecycle().removeObserver(this); owner.getLifecycle().removeObserver(this);
deliver();
cleanup(context); cleanup(context);
} else
Log.i("Task deferring " + state);
} }
}); });
} }

Loading…
Cancel
Save