prevent NPE

This commit is contained in:
Milos Kozak 2021-10-06 22:22:35 +02:00
parent b4e7d4b720
commit a9e08f4a1e
2 changed files with 2 additions and 1 deletions

View file

@ -35,6 +35,7 @@ fun EffectiveProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObjec
.put("originalPercentage", originalPercentage)
.put("originalDuration", originalDuration)
.put("originalEnd", originalEnd)
.put("notes", originalCustomizedName)
.also {
if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId)
if (interfaceIDs.pumpType != null) it.put("pumpType", interfaceIDs.pumpType!!.name)

View file

@ -1081,7 +1081,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
@NonNull @Override
public String shortStatus(boolean veryShort) {
StringBuilder ret = new StringBuilder();
if (connectionService.getLastConnected() != 0) {
if (connectionService != null && connectionService.getLastConnected() != 0) {
long agoMsec = dateUtil.now() - connectionService.getLastConnected();
int agoMin = (int) (agoMsec / 60d / 1000d);
ret.append(resourceHelper.gs(R.string.short_status_last_connected, agoMin)).append("\n");