make new instances of LocalRepoActivity show state properly

LocalRepoActivity needs to get the current state of the LocalRepoService so
it can correctly represent it in the UI.

fixes #25 https://gitlab.com/fdroid/fdroidclient/issues/25
This commit is contained in:
Hans-Christoph Steiner 2014-05-09 14:18:43 -04:00
parent 776ad3f540
commit 09cbd036fa
2 changed files with 8 additions and 0 deletions

View File

@ -327,4 +327,8 @@ public class FDroidApp extends Application {
}
}
}
public static boolean isLocalRepoServiceRunnig() {
return localRepoServiceIsBound;
}
}

View File

@ -58,6 +58,7 @@ public class LocalRepoActivity extends Activity {
public void onResume() {
super.onResume();
resetNetworkInfo();
setRepoSwitchChecked(FDroidApp.isLocalRepoServiceRunnig());
LocalBroadcastManager.getInstance(this).registerReceiver(onWifiChange,
new IntentFilter(WifiStateChangeService.BROADCAST));
@ -71,6 +72,9 @@ public class LocalRepoActivity extends Activity {
// start repo by default
FDroidApp.startLocalRepoService(LocalRepoActivity.this);
// reset the timer if viewing this Activity again
if (stopTimer != null)
stopTimer.cancel();
// automatically turn off after 15 minutes
stopTimer = new Timer();
stopTimer.schedule(new TimerTask() {