Use transient keyword instead of Gson annotation for PodSessionState members that should be exluded of (de)serialization

This commit is contained in:
Bart Sopers 2020-05-06 21:41:33 +02:00
parent f3c4b4e5e7
commit bafffad44a
3 changed files with 14 additions and 32 deletions

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.defs.state; package info.nightscout.androidaps.plugins.pump.omnipod.defs.state;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
@ -34,42 +33,26 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class PodSessionState extends PodState { public class PodSessionState extends PodState {
@Inject AAPSLogger aapsLogger; @Inject transient AAPSLogger aapsLogger;
@Inject SP sp; @Inject transient SP sp;
@Inject OmnipodUtil omnipodUtil; @Inject transient OmnipodUtil omnipodUtil;
@Expose
private final Map<AlertSlot, AlertType> configuredAlerts;
@Expose
private transient PodStateChangedHandler stateChangedHandler; private transient PodStateChangedHandler stateChangedHandler;
@Expose
private DateTime activatedAt;
@Expose
private DateTime expiresAt;
@Expose
private final FirmwareVersion piVersion;
@Expose
private final FirmwareVersion pmVersion;
@Expose
private final int lot;
@Expose
private final int tid;
@Expose
private Double reservoirLevel;
@Expose
private boolean suspended;
@Expose private final Map<AlertSlot, AlertType> configuredAlerts;
private DateTimeZone timeZone; private DateTimeZone timeZone;
@Expose private DateTime activatedAt;
private DateTime expiresAt;
private final FirmwareVersion piVersion;
private final FirmwareVersion pmVersion;
private final int lot;
private final int tid;
private Double reservoirLevel;
private boolean suspended;
private NonceState nonceState; private NonceState nonceState;
@Expose
private SetupProgress setupProgress; private SetupProgress setupProgress;
@Expose
private AlertSet activeAlerts; private AlertSet activeAlerts;
@Expose
private BasalSchedule basalSchedule; private BasalSchedule basalSchedule;
@Expose
private DeliveryStatus lastDeliveryStatus; private DeliveryStatus lastDeliveryStatus;
public PodSessionState(DateTimeZone timeZone, int address, FirmwareVersion piVersion, public PodSessionState(DateTimeZone timeZone, int address, FirmwareVersion piVersion,

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs.state;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
public abstract class PodState { public abstract class PodState {
protected final int address; protected final int address;

View file

@ -136,7 +136,7 @@ public class OmnipodUtil {
.registerTypeAdapter(DateTimeZone.class, (JsonDeserializer<DateTimeZone>) (json, typeOfT, context) -> .registerTypeAdapter(DateTimeZone.class, (JsonDeserializer<DateTimeZone>) (json, typeOfT, context) ->
DateTimeZone.forID(json.getAsString())); DateTimeZone.forID(json.getAsString()));
return gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); return gsonBuilder.create();
} }
@ -195,7 +195,7 @@ public class OmnipodUtil {
} }
public Integer getNextPodAddress() { public Integer getNextPodAddress() {
if(sp.contains(OmnipodConst.Prefs.NextPodAddress)) { if (sp.contains(OmnipodConst.Prefs.NextPodAddress)) {
int nextPodAddress = sp.getInt(OmnipodConst.Prefs.NextPodAddress, 0); int nextPodAddress = sp.getInt(OmnipodConst.Prefs.NextPodAddress, 0);
if (OmnipodManager.isValidAddress(nextPodAddress)) { if (OmnipodManager.isValidAddress(nextPodAddress)) {
return nextPodAddress; return nextPodAddress;