Overview: fix predictions checkbox disappearing after unchecking it.

This commit is contained in:
Johannes Mockenhaupt 2017-11-18 18:44:59 +01:00
parent a293f86978
commit d21a2bd691
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -1170,8 +1170,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
cobView.setText(cobText);
}
boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.request.hasPredictions;
if (showPrediction) {
boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions;
if (predictionsAvailable) {
showPredictionView.setVisibility(View.VISIBLE);
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
} else {
@ -1214,7 +1214,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// ****** GRAPH *******
// allign to hours
// align to hours
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.MILLISECOND, 0);
@ -1226,7 +1226,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
long toTime;
long fromTime;
long endTime;
if (showPrediction) {
if (predictionsAvailable && showPredictionView.isChecked()) {
int predHours = (int) (Math.ceil(finalLastRun.constraintsProcessed.getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
predHours = Math.min(2, predHours);
predHours = Math.max(0, predHours);
@ -1295,7 +1295,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.addInRangeArea(bgGraph, fromTime, endTime, lowLine, highLine);
// **** BG ****
if (showPrediction)
if (predictionsAvailable && showPredictionView.isChecked())
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
else
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, null);