- change events to kotlin

- some smaller changes
This commit is contained in:
Andy Rozman 2020-03-14 17:59:52 +00:00
parent ff3409d650
commit 4c14e2e364
8 changed files with 68 additions and 79 deletions

View file

@ -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 {

View file

@ -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);
}

View file

@ -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 {
}

View file

@ -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()

View file

@ -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 + "]";
}
}

View file

@ -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 + "]")
}
}

View file

@ -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 {
}

View file

@ -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()