- change events to kotlin
- some smaller changes
This commit is contained in:
parent
ff3409d650
commit
4c14e2e364
8 changed files with 68 additions and 79 deletions
|
@ -543,6 +543,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
} else {
|
} else {
|
||||||
String podState = SP.getString(OmnipodConst.Prefs.PodState, null);
|
String podState = SP.getString(OmnipodConst.Prefs.PodState, null);
|
||||||
|
|
||||||
|
LOG.info("PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
||||||
|
|
||||||
if (podState != null) {
|
if (podState != null) {
|
||||||
podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
||||||
OmnipodUtil.setPodSessionState(podSessionState);
|
OmnipodUtil.setPodSessionState(podSessionState);
|
||||||
|
@ -553,14 +555,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
if (podSessionState != null) {
|
if (podSessionState != null) {
|
||||||
LOG.debug("PodSessionState (saved): " + podSessionState);
|
LOG.debug("PodSessionState (saved): " + podSessionState);
|
||||||
|
|
||||||
// TODO handle if session state too old
|
|
||||||
|
|
||||||
// TODO load session
|
|
||||||
|
|
||||||
if (!isRefresh) {
|
if (!isRefresh) {
|
||||||
pumpState = PumpDriverState.Initialized;
|
pumpState = PumpDriverState.Initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO handle if session state too old
|
||||||
getPodPumpStatus();
|
getPodPumpStatus();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -252,7 +252,9 @@ public class PodSessionState extends PodState {
|
||||||
|
|
||||||
private void handleUpdates() {
|
private void handleUpdates() {
|
||||||
Gson gson = OmnipodUtil.getGsonInstance();
|
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) {
|
if (stateChangedHandler != null) {
|
||||||
stateChangedHandler.handle(this);
|
stateChangedHandler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
|
||||||
}
|
|
|
@ -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()
|
|
@ -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 + "]";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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 + "]")
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 {
|
|
||||||
}
|
|
|
@ -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()
|
Loading…
Reference in a new issue