diff --git a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java index 5fae3136fa..afb1a18540 100644 --- a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java @@ -21,6 +21,7 @@ import butterknife.OnLongClick; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.graphData.GraphData; import info.nightscout.utils.DateUtil; @@ -56,6 +57,12 @@ public class HistoryBrowseActivity extends AppCompatActivity { private int rangeToDisplay = 24; // for graph private long start; + IobCobCalculatorPlugin iobCobCalculatorPlugin; + + public HistoryBrowseActivity() { + iobCobCalculatorPlugin = new IobCobCalculatorPlugin(); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -195,7 +202,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { // ------------------ 1st graph - final GraphData graphData = new GraphData(bgGraph); + final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin()); // **** In range Area **** graphData.addInRangeArea(fromTime, toTime, lowLine, highLine); @@ -223,7 +230,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { // ------------------ 2nd graph - final GraphData secondGraphData = new GraphData(iobGraph); + final GraphData secondGraphData = new GraphData(iobGraph, iobCobCalculatorPlugin); boolean useIobForScale = false; boolean useCobForScale = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 16b1edd10c..abcda1246a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -131,7 +131,7 @@ public class IobCobCalculatorPlugin implements PluginBase { return -1; } - private IobCobCalculatorPlugin() { + public IobCobCalculatorPlugin() { MainApp.bus().register(this); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 75d5c6bbb1..fef0a5d4bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1362,7 +1362,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // ------------------ 1st graph Profiler.log(log, from + " - 1st graph - START", updateGUIStart); - final GraphData graphData = new GraphData(bgGraph); + final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin()); // **** In range Area **** graphData.addInRangeArea(fromTime, endTime, lowLine, highLine); @@ -1393,7 +1393,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // ------------------ 2nd graph Profiler.log(log, from + " - 2nd graph - START", updateGUIStart); - final GraphData secondGraphData = new GraphData(iobGraph); + final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin()); boolean useIobForScale = false; boolean useCobForScale = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java index 80e590dff8..02bb1a7b3d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java @@ -53,9 +53,12 @@ public class GraphData { private String units; private List series = new ArrayList<>(); - public GraphData(GraphView graph) { + private IobCobCalculatorPlugin iobCobCalculatorPlugin; + + public GraphData(GraphView graph, IobCobCalculatorPlugin iobCobCalculatorPlugin) { units = MainApp.getConfigBuilder().getProfileUnits(); this.graph = graph; + this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; } public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, APSResult apsResult) {