From 66c567f0e70f1db601867d155f8984793c6670c5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 12 May 2020 12:33:23 +0200 Subject: [PATCH] lint & deprecation --- .../info/nightscout/androidaps/MainApp.java | 1 + .../pump/medtronic/data/dto/BasalProfile.java | 4 --- .../medtronic/data/dto/TempBasalPair.java | 3 +-- .../sensitivity/SensitivityOref1Plugin.java | 26 ++++++++----------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index a00c681e81..126ba47d22 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -113,6 +113,7 @@ public class MainApp extends DaggerApplication { .build(); } + @SuppressWarnings("deprecation") private void registerLocalBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(Intents.ACTION_NEW_TREATMENT); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java index 61b235f1d2..f5ff77cf72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.java @@ -363,10 +363,6 @@ public class BasalProfile { } - private boolean isLogEnabled() { - return L.isEnabled(LTag.PUMPCOMM); - } - public boolean verify(PumpType pumpType) { try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java index caac54e122..bf3e771b1e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java @@ -42,8 +42,7 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo public TempBasalPair(AAPSLogger aapsLogger, byte[] response) { super(); - if (L.isEnabled(LTag.PUMPCOMM)) - aapsLogger.debug(LTag.PUMPBTCOMM, "Received TempBasal response: " + ByteUtil.getHex(response)); + aapsLogger.debug(LTag.PUMPBTCOMM, "Received TempBasal response: " + ByteUtil.getHex(response)); isPercent = response[0] == 1; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java index 5740c7a5d1..fec1b6d960 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java @@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.sensitivity; import androidx.collection.LongSparseArray; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -61,7 +63,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { this.dateUtil = dateUtil; } - @Override + @NotNull @Override public AutosensResult detectSensitivity(IobCobCalculatorInterface iobCobCalculatorPlugin, long fromTime, long toTime) { // todo this method is called from the IobCobCalculatorPlugin, which leads to a circular // dependency, this should be avoided @@ -92,7 +94,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { //[0] = 8 hour //[1] = 24 hour //Deviationshour has DeviationsArray - List deviationsHour = Arrays.asList(new ArrayList(), new ArrayList()); + List> deviationsHour = Arrays.asList(new ArrayList<>(), new ArrayList<>()); List pastSensitivityArray = Arrays.asList("", ""); List sensResultArray = Arrays.asList("", ""); List ratioArray = Arrays.asList(0d, 0d); @@ -118,7 +120,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { //hoursegment = 0 = 8 hour //hoursegment = 1 = 24 hour while (hoursegment < deviationsHour.size()) { - ArrayList deviationsArray = deviationsHour.get(hoursegment); + ArrayList deviationsArray = deviationsHour.get(hoursegment); String pastSensitivity = pastSensitivityArray.get(hoursegment); // reset deviations after site change @@ -144,8 +146,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { deviationsArray.add(deviation); - for (int i = 0; i < autosensData.extraDeviation.size(); i++) - deviationsArray.add(autosensData.extraDeviation.get(i)); + deviationsArray.addAll(autosensData.extraDeviation); if (deviationsArray.size() > deviationCategory.get(hoursegment)) { deviationsArray.remove(0); @@ -170,13 +171,12 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { // this dampens any large sensitivity changes detected based on too little data, without ignoring them completely for (int i = 0; i < deviationsHour.size(); i++) { - ArrayList deviations = deviationsHour.get(i); + ArrayList deviations = deviationsHour.get(i); getAapsLogger().debug(LTag.AUTOSENS, "Using most recent " + deviations.size() + " deviations"); if (deviations.size() < deviationCategory.get(i)) { int pad = (int) Math.round((1 - (double) deviations.size() / deviationCategory.get(i)) * 18); getAapsLogger().debug(LTag.AUTOSENS, "Adding " + pad + " more zero deviations"); for (int d = 0; d < pad; d++) { - ; deviations.add(0d); } } @@ -190,11 +190,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { ArrayList deviationsArray = deviationsHour.get(hourused); String pastSensitivity = pastSensitivityArray.get(hourused); String sensResult = "(8 hours) "; - String senstime = sensResult; - if (hourused == 1) { - senstime = "(24 hours) "; - sensResult = senstime; - } + if (hourused == 1) sensResult = "(24 hours) "; String ratioLimit = ""; Double[] deviations = new Double[deviationsArray.size()]; @@ -212,10 +208,10 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { double basalOff = 0; if (pSensitive < 0) { // sensitive - basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); + basalOff = pSensitive * (60.0 / 5) / Profile.toMgdl(sens, profile.getUnits()); sensResult += "Excess insulin sensitivity detected"; } else if (pResistant > 0) { // resistant - basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); + basalOff = pResistant * (60.0 / 5) / Profile.toMgdl(sens, profile.getUnits()); sensResult += "Excess insulin resistance detected"; } else { sensResult += "Sensitivity normal"; @@ -239,7 +235,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { if (ratioArray.get(0) < ratioArray.get(1)) { key = 0; } - String message = hoursDetection.get(key) + " of sensitivity used"; + //String message = hoursDetection.get(key) + " of sensitivity used"; AutosensResult output = fillResult(ratioArray.get(key), current.cob, pastSensitivityArray.get(key), ratioLimitArray.get(key), sensResultArray.get(key) + comparison, deviationsHour.get(key).size());