Fixed code so IA is also correctly displayed in ssecondary if it is the only selected option.

This commit is contained in:
Paulus 2019-07-13 17:46:57 +02:00
parent 96d20d835f
commit d528e800f6
2 changed files with 14 additions and 6 deletions

View file

@ -1560,7 +1560,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.formatAxis(fromTime, endTime);
if(SP.getBoolean("showactivityprimary", true)) {
graphData.addActivity(fromTime, endTime, 1d);
graphData.addActivity(fromTime, endTime, false,1d);
}
// Treatments
@ -1588,6 +1588,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
boolean useDevForScale = false;
boolean useRatioForScale = false;
boolean useDSForScale = false;
boolean useIAForScale = false;
if (SP.getBoolean("showiob", true)) {
useIobForScale = true;
@ -1597,6 +1598,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
useDevForScale = true;
} else if (SP.getBoolean("showratios", false)) {
useRatioForScale = true;
} else if (SP.getBoolean("showactivitysecondary", false)) {
useIAForScale = true;
} else if (SP.getBoolean("showdevslope", false)) {
useDSForScale = true;
}
@ -1610,7 +1613,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (SP.getBoolean("showratios", false))
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
if(SP.getBoolean("showactivitysecondary", true))
secondGraphData.addActivity(fromTime, endTime, 1d);
secondGraphData.addActivity(fromTime, endTime, useIAForScale,1d);
if (SP.getBoolean("showdevslope", false) && MainApp.devBranch)
secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d);
@ -1627,6 +1630,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|| SP.getBoolean("showcob", true)
|| SP.getBoolean("showdeviations", false)
|| SP.getBoolean("showratios", false)
|| SP.getBoolean("showactivitysecondary", false)
|| SP.getBoolean("showdevslope", false)) {
iobGraph.setVisibility(View.VISIBLE);
} else {

View file

@ -346,7 +346,7 @@ public class GraphData {
? Profile.fromMgdlToUnits(bgReadingsArray.get(0).value, units) : Profile.fromMgdlToUnits(100, units);
}
public void addActivity(long fromTime, long toTime, double scale) {
public void addActivity(long fromTime, long toTime, boolean useForScale, double scale) {
FixedLineGraphSeries<ScaledDataPoint> actSeriesHist;
List<ScaledDataPoint> actArrayHist = new ArrayList<>();
FixedLineGraphSeries<ScaledDataPoint> actSeriesPred;
@ -369,9 +369,6 @@ public class GraphData {
actArrayPred.add(new ScaledDataPoint(time, act, actScale));
}
double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05);
actScale.setMultiplier(maxY*scale / maxIAValue);
ScaledDataPoint[] actData = new ScaledDataPoint[actArrayHist.size()];
actData = actArrayHist.toArray(actData);
actSeriesHist = new FixedLineGraphSeries<>(actData);
@ -392,6 +389,13 @@ public class GraphData {
paint.setColor(MainApp.gc(R.color.activity));
actSeriesPred.setCustomPaint(paint);
double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05);
if (useForScale) {
maxY = maxIAValue;
minY = -maxIAValue;
}
actScale.setMultiplier(maxY * scale / maxIAValue);
addSeries(actSeriesPred);
}