From 4c14e2e364c350f0a14a6bc5d538133f9e002b69 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sat, 14 Mar 2020 17:59:52 +0000 Subject: [PATCH] - change events to kotlin - some smaller changes --- .../pump/omnipod/OmnipodPumpPlugin.java | 7 +-- .../omnipod/defs/state/PodSessionState.java | 4 +- .../EventOmnipodAcknowledgeAlertsChanged.java | 9 --- .../EventOmnipodAcknowledgeAlertsChanged.kt | 8 +++ .../EventOmnipodDeviceStatusChange.java | 56 ------------------- .../events/EventOmnipodDeviceStatusChange.kt | 46 +++++++++++++++ .../events/EventOmnipodPumpValuesChanged.java | 9 --- .../events/EventOmnipodPumpValuesChanged.kt | 8 +++ 8 files changed, 68 insertions(+), 79 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 973b5105f5..1bb491694e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -543,6 +543,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } else { String podState = SP.getString(OmnipodConst.Prefs.PodState, null); + LOG.info("PodSessionState-SP: loaded from SharedPreferences: " + podState); + if (podState != null) { podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class); OmnipodUtil.setPodSessionState(podSessionState); @@ -553,14 +555,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (podSessionState != null) { LOG.debug("PodSessionState (saved): " + podSessionState); - // TODO handle if session state too old - - // TODO load session - if (!isRefresh) { pumpState = PumpDriverState.Initialized; } + // TODO handle if session state too old getPodPumpStatus(); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java index 05501acaa3..550e986740 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java @@ -252,7 +252,9 @@ public class PodSessionState extends PodState { private void handleUpdates() { Gson gson = OmnipodUtil.getGsonInstance(); - SP.putString(OmnipodConst.Prefs.PodState, gson.toJson(this)); + String gsonValue = gson.toJson(this); + LOG.info("PodSessionState-SP: Saved Session State to SharedPreferences: " + gsonValue); + SP.putString(OmnipodConst.Prefs.PodState, gsonValue); if (stateChangedHandler != null) { stateChangedHandler.handle(this); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.java deleted file mode 100644 index a11a0ff0c2..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.java +++ /dev/null @@ -1,9 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.events; - -import info.nightscout.androidaps.events.Event; - -/** - * Created by andy on 04.06.2018. - */ -public class EventOmnipodAcknowledgeAlertsChanged extends Event { -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt new file mode 100644 index 0000000000..9938319858 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodAcknowledgeAlertsChanged.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.events + +import info.nightscout.androidaps.events.Event + +/** + * Created by andy on 04.06.2018. + */ +class EventOmnipodAcknowledgeAlertsChanged : Event() \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.java deleted file mode 100644 index f0b7a98a60..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.java +++ /dev/null @@ -1,56 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.events; - -import info.nightscout.androidaps.events.Event; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; - -/** - * Created by andy on 4.8.2019 - */ -public class EventOmnipodDeviceStatusChange extends Event { - - public RileyLinkServiceState rileyLinkServiceState; - public RileyLinkError rileyLinkError; - - public PodSessionState podSessionState; - public String errorDescription; - public PodDeviceState podDeviceState; - - - public EventOmnipodDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState) { - this(rileyLinkServiceState, null); - } - - - public EventOmnipodDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState, RileyLinkError rileyLinkError) { - this.rileyLinkServiceState = rileyLinkServiceState; - this.rileyLinkError = rileyLinkError; - } - - - public EventOmnipodDeviceStatusChange(PodSessionState podSessionState) { - this.podSessionState = podSessionState; - } - - - public EventOmnipodDeviceStatusChange(String errorDescription) { - this.errorDescription = errorDescription; - } - - public EventOmnipodDeviceStatusChange(PodDeviceState podDeviceState, String errorDescription) { - this.podDeviceState = podDeviceState; - this.errorDescription = errorDescription; - } - - - @Override - public String toString() { - return "EventOmnipodDeviceStatusChange [" // - + "rileyLinkServiceState=" + rileyLinkServiceState - + ", rileyLinkError=" + rileyLinkError // - + ", podSessionState=" + podSessionState // - + ", podDeviceState=" + podDeviceState + "]"; - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.kt new file mode 100644 index 0000000000..db46550a05 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodDeviceStatusChange.kt @@ -0,0 +1,46 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.events + +import info.nightscout.androidaps.events.Event +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState +import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState + +/** + * Created by andy on 4.8.2019 + */ +class EventOmnipodDeviceStatusChange : Event { + + var rileyLinkServiceState: RileyLinkServiceState? = null + var rileyLinkError: RileyLinkError? = null + var podSessionState: PodSessionState? = null + var errorDescription: String? = null + var podDeviceState: PodDeviceState? = null + + @JvmOverloads + constructor(rileyLinkServiceState: RileyLinkServiceState?, rileyLinkError: RileyLinkError? = null) { + this.rileyLinkServiceState = rileyLinkServiceState + this.rileyLinkError = rileyLinkError + } + + constructor(podSessionState: PodSessionState?) { + this.podSessionState = podSessionState + } + + constructor(errorDescription: String?) { + this.errorDescription = errorDescription + } + + constructor(podDeviceState: PodDeviceState?, errorDescription: String?) { + this.podDeviceState = podDeviceState + this.errorDescription = errorDescription + } + + override fun toString(): String { + return ("EventOmnipodDeviceStatusChange [" // + + "rileyLinkServiceState=" + rileyLinkServiceState + + ", rileyLinkError=" + rileyLinkError // + + ", podSessionState=" + podSessionState // + + ", podDeviceState=" + podDeviceState + "]") + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.java deleted file mode 100644 index b12b32007f..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.java +++ /dev/null @@ -1,9 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.events; - -import info.nightscout.androidaps.events.Event; - -/** - * Created by andy on 04.06.2018. - */ -public class EventOmnipodPumpValuesChanged extends Event { -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt new file mode 100644 index 0000000000..5b0f03a241 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/events/EventOmnipodPumpValuesChanged.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.events + +import info.nightscout.androidaps.events.Event + +/** + * Created by andy on 04.06.2018. + */ +class EventOmnipodPumpValuesChanged : Event() \ No newline at end of file