From 97d0140614063f84f863f17e071c828bdf1390a4 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 19 Aug 2017 19:56:16 +0200 Subject: [PATCH] Remove now unused dia, insulinInterfaceId from Treatment. --- .../androidaps/data/DetailedBolusInfo.java | 1 - .../androidaps/db/ExtendedBolus.java | 2 +- .../androidaps/db/TemporaryBasal.java | 2 +- .../nightscout/androidaps/db/Treatment.java | 23 ------------------- .../InsulinFastacting/ActivityGraph.java | 11 ++++----- .../plugins/PumpDanaR/DanaRPlugin.java | 4 ++-- .../PumpDanaRKorean/DanaRKoreanPlugin.java | 6 ++--- .../plugins/PumpDanaRv2/DanaRv2Plugin.java | 6 ++--- .../plugins/Treatments/TreatmentsPlugin.java | 4 ++-- 9 files changed, 15 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java index aa54ac100f..2d928a5541 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java @@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.InsulinInterface; public class DetailedBolusInfo { public long date = System.currentTimeMillis(); - public InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin(); public String eventType = CareportalEvent.MEALBOLUS; public double insulin = 0; public double carbs = 0; diff --git a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java index 32a9eca24c..0bd929030f 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/db/ExtendedBolus.java @@ -187,7 +187,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface { if (calcdate > dia_ago && calcdate <= time) { double tempBolusSize = absoluteRate() * spacing / 60d; - Treatment tempBolusPart = new Treatment(insulinInterface, dia); + Treatment tempBolusPart = new Treatment(); tempBolusPart.insulin = tempBolusSize; tempBolusPart.date = calcdate; diff --git a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java index 751e679699..3c8f95f5af 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java @@ -223,7 +223,7 @@ public class TemporaryBasal implements Interval { double tempBolusSize = netBasalRate * tempBolusSpacing / 60d; netBasalAmount += tempBolusSize; - Treatment tempBolusPart = new Treatment(insulinInterface, dia); + Treatment tempBolusPart = new Treatment(); tempBolusPart.insulin = tempBolusSize; tempBolusPart.date = calcdate; diff --git a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java index 971e1d55f1..fe16a54049 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java +++ b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java @@ -50,32 +50,9 @@ public class Treatment implements DataPointWithLabelInterface { @DatabaseField public boolean isSMB = false; - @DatabaseField - public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN; - @DatabaseField - public double dia = Constants.defaultDIA; - public Treatment() { } - public Treatment(long date) { - this.date = date; - } - - public Treatment(InsulinInterface insulin) { - insulinInterfaceID = insulin.getId(); - dia = insulin.getDia(); - } - - public Treatment(InsulinInterface insulin, double dia) { - insulinInterfaceID = insulin.getId(); - this.dia = dia; - } - - public long getMillisecondsFromStart() { - return System.currentTimeMillis() - date; - } - public String toString() { return "Treatment{" + "date= " + date + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java index 5458337782..3eda06fb37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java @@ -9,7 +9,6 @@ import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.LineGraphSeries; import java.util.ArrayList; -import java.util.Date; import java.util.List; import info.nightscout.androidaps.data.Iob; @@ -39,14 +38,14 @@ public class ActivityGraph extends GraphView { double dia = insulin.getDia(); int hours = (int) Math.floor(dia + 1); - Treatment t = new Treatment(insulin, dia); + Treatment t = new Treatment(); t.date = 0; t.insulin = 1d; LineGraphSeries activitySeries = null; LineGraphSeries iobSeries = null; - List activityArray = new ArrayList(); - List iobArray = new ArrayList(); + List activityArray = new ArrayList<>(); + List iobArray = new ArrayList<>(); for (long time = 0; time <= hours * 60 * 60 * 1000; time += 5 * 60 * 1000L) { Iob iob = t.iobCalc(time, dia); @@ -56,7 +55,7 @@ public class ActivityGraph extends GraphView { DataPoint[] activityDataPoints = new DataPoint[activityArray.size()]; activityDataPoints = activityArray.toArray(activityDataPoints); - addSeries(activitySeries = new LineGraphSeries(activityDataPoints)); + addSeries(activitySeries = new LineGraphSeries<>(activityDataPoints)); activitySeries.setThickness(8); getViewport().setXAxisBoundsManual(true); @@ -68,7 +67,7 @@ public class ActivityGraph extends GraphView { DataPoint[] iobDataPoints = new DataPoint[iobArray.size()]; iobDataPoints = iobArray.toArray(iobDataPoints); - getSecondScale().addSeries(iobSeries = new LineGraphSeries(iobDataPoints)); + getSecondScale().addSeries(iobSeries = new LineGraphSeries<>(iobDataPoints)); iobSeries.setDrawBackground(true); iobSeries.setColor(Color.MAGENTA); iobSeries.setBackgroundColor(Color.argb(70, 255, 0, 255)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index 2e01ee662d..bc5b23ad92 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -104,7 +104,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C pumpDescription.isRefillingCapable = true; } - ServiceConnection mConnection = new ServiceConnection() { + private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { log.debug("Service is disconnected"); @@ -298,7 +298,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - Treatment t = new Treatment(detailedBolusInfo.insulinInterface); + Treatment t = new Treatment(); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t); PumpEnactResult result = new PumpEnactResult(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index 84552946ae..354db54c48 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -72,8 +72,6 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf public static PumpDescription pumpDescription = new PumpDescription(); - String textStatus = ""; - public DanaRKoreanPlugin() { useExtendedBoluses = SP.getBoolean("danar_useextended", false); @@ -107,7 +105,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf pumpDescription.isRefillingCapable = true; } - ServiceConnection mConnection = new ServiceConnection() { + private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { log.debug("Service is disconnected"); @@ -301,7 +299,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - Treatment t = new Treatment(detailedBolusInfo.insulinInterface); + Treatment t = new Treatment(); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index 0697a69af7..ca1e1e6e3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -73,8 +73,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, public static PumpDescription pumpDescription = new PumpDescription(); public DanaRv2Plugin() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); - Context context = MainApp.instance().getApplicationContext(); Intent intent = new Intent(context, DanaRv2ExecutionService.class); context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); @@ -105,7 +103,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, pumpDescription.isRefillingCapable = true; } - ServiceConnection mConnection = new ServiceConnection() { + private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { log.debug("Service is disconnected"); @@ -288,7 +286,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history - Treatment t = new Treatment(detailedBolusInfo.insulinInterface); + Treatment t = new Treatment(); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 5178c8484e..0f5a6c582e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -413,7 +413,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) { - Treatment treatment = new Treatment(detailedBolusInfo.insulinInterface); + Treatment treatment = new Treatment(); treatment.date = detailedBolusInfo.date; treatment.source = detailedBolusInfo.source; treatment.pumpId = detailedBolusInfo.pumpId; @@ -427,7 +427,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(treatment); //log.debug("Adding new Treatment record" + treatment.toString()); if (detailedBolusInfo.carbTime != 0) { - Treatment carbsTreatment = new Treatment(detailedBolusInfo.insulinInterface); + Treatment carbsTreatment = new Treatment(); carbsTreatment.source = detailedBolusInfo.source; carbsTreatment.pumpId = detailedBolusInfo.pumpId; // but this should never happen carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records