Small code improvements for PodStateManager

This commit is contained in:
Bart Sopers 2020-08-08 18:52:49 +02:00
parent 76d267dce4
commit 2a73127202
4 changed files with 13 additions and 8 deletions

View file

@ -128,11 +128,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
podStateManager.setStateChangedHandler(manager -> {
// Handle pod state changes
// FIXME only set once (?) (before instantiating AapsOmnipodManager)
// Maybe not, it seems to not only set something, but also fire an event
omnipodUtil.setPodStateManager(manager);
updatePumpStatus(manager);
omnipodUtil.notifyDeviceStatusChanged();
});
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager);

View file

@ -122,8 +122,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUtil, omnipodUIPostprocessor, aapsOmnipodManager);
} else {
aapsOmnipodManager = instance;
omnipodUtil.setPodStateManager(instance.getPodStateManager());
aapsOmnipodManager = instance;
}
}

View file

@ -14,7 +14,6 @@ public class OmnipodConst {
public class Prefs {
public static final String PodState = Prefix + "pod_state";
public static final String NextPodAddress = Prefix + "next_pod_address";
public static final int BeepBasalEnabled = R.string.key_omnipod_beep_basal_enabled;
public static final int BeepBolusEnabled = R.string.key_omnipod_beep_bolus_enabled;
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled;

View file

@ -138,10 +138,16 @@ public class OmnipodUtil {
return gsonBuilder.create();
}
public void setPodStateManager(PodStateManager podStateManager) {
if (podStateManager == null) {
throw new IllegalArgumentException("Pod state manager can not be null");
}
omnipodPumpStatus.podStateManager = podStateManager;
rxBus.send(new EventOmnipodDeviceStatusChange(podStateManager));
notifyDeviceStatusChanged();
}
public void notifyDeviceStatusChanged() {
rxBus.send(new EventOmnipodDeviceStatusChange(omnipodPumpStatus.podStateManager));
}
@ -166,6 +172,9 @@ public class OmnipodUtil {
public PodStateManager getPodStateManager() {
if (omnipodPumpStatus.podStateManager == null) {
throw new IllegalStateException("Pod state manager is null");
}
return omnipodPumpStatus.podStateManager;
}