Simplify operations watcher

This commit is contained in:
M66B
2019-03-06 16:36:20 +00:00
parent 4b7caeb219
commit 80c28636e6
2 changed files with 129 additions and 117 deletions

View File

@@ -0,0 +1,28 @@
package eu.faircode.email;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
public class TwoStateOwner implements LifecycleOwner {
private LifecycleRegistry registry;
TwoStateOwner() {
registry = new LifecycleRegistry(this);
}
void start() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_START);
}
void stop() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_STOP);
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return registry;
}
}