Prevent crash

This commit is contained in:
M66B 2019-03-25 19:20:23 +00:00
parent 6ed02843df
commit e0db116401
2 changed files with 8 additions and 2 deletions

View File

@ -69,6 +69,7 @@ public class ServiceTileUnseen extends TileService {
@Override
public void onDestroy() {
owner.destroy();
super.onDestroy();
}

View File

@ -19,7 +19,7 @@ public class TwoStateOwner implements LifecycleOwner {
owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
destroy();
}
});
}
@ -33,10 +33,15 @@ public class TwoStateOwner implements LifecycleOwner {
}
void restart() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
stop();
start();
}
void destroy() {
if (!registry.getCurrentState().equals(Lifecycle.State.DESTROYED))
registry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
}
@NonNull
@Override
public Lifecycle getLifecycle() {