Catch NetworkState changes correctly
This commit is contained in:
parent
3fb17e6869
commit
55ea10e88f
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventChargingState;
|
||||
import info.nightscout.androidaps.events.EventNetworkChange;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
@ -113,6 +114,7 @@ public class NSClientPlugin extends PluginBase {
|
|||
MainApp.bus().unregister(this);
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
context.unregisterReceiver(networkChangeReceiver);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
@ -142,6 +144,11 @@ public class NSClientPlugin extends PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventChargingState ev) {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNetworkChange ev) {
|
||||
boolean wifiOnly = SP.getBoolean(R.string.key_ns_wifionly, false);
|
||||
|
@ -163,8 +170,10 @@ public class NSClientPlugin extends PluginBase {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventAppExit ignored) {
|
||||
if (nsClientService != null)
|
||||
if (nsClientService != null) {
|
||||
MainApp.instance().getApplicationContext().unbindService(mConnection);
|
||||
MainApp.instance().getApplicationContext().unregisterReceiver(networkChangeReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -33,7 +33,6 @@ import info.nightscout.androidaps.db.DbRequest;
|
|||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
|
@ -251,6 +250,7 @@ public class NSClientService extends Service {
|
|||
private Emitter.Listener onDisconnect = new Emitter.Listener() {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
log.debug("disconnect reason: {}", args);
|
||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue