From dce29cf665087d98c7696ad69524cd6de09f80fe Mon Sep 17 00:00:00 2001 From: bugy Date: Sun, 5 Nov 2017 12:34:08 +0100 Subject: [PATCH] #109,#110: fixed not restored unit states after restoring minimized application --- .../net/buggy/shoplist/ShopListActivity.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/SheLi/src/main/java/net/buggy/shoplist/ShopListActivity.java b/SheLi/src/main/java/net/buggy/shoplist/ShopListActivity.java index 73a3e20..8e3fd59 100644 --- a/SheLi/src/main/java/net/buggy/shoplist/ShopListActivity.java +++ b/SheLi/src/main/java/net/buggy/shoplist/ShopListActivity.java @@ -168,19 +168,34 @@ public void run() { }); synchronizer.start(); - if (savedInstanceState == null) { + if (savedInstanceState != null) { + restoreState(savedInstanceState); + } + + initMenu(); + } + + @Override + protected void onStart() { + super.onStart(); + if (activeUnits.isEmpty()) { final UnitNavigator navigator = navigators.get(0); currentNavigatorName = navigator.getText(); navigator.navigate(); } else { - restoreState(savedInstanceState); - restartUnits(); } + } - initMenu(); + @Override + protected void onStop() { + super.onStop(); + + for (UnitDescriptor unit : activeUnits) { + unit.getUnit().stop(); + } } @Override @@ -625,15 +640,6 @@ public void stopUnit(Unit unit) { } } - @Override - protected void onStop() { - for (UnitDescriptor unit : activeUnits) { - unit.getUnit().stop(); - } - - super.onStop(); - } - private void stopUnit(UnitDescriptor descriptor) { activeUnits.remove(descriptor);