allow to change x axis scale

This commit is contained in:
Milos Kozak 2017-05-04 23:51:04 +02:00
parent 05d9f16031
commit 14a56842ee

View file

@ -170,6 +170,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
boolean smallWidth;
private int rangeToDisplay = 6; // for graph
Handler sLoopHandler = new Handler();
Runnable sRefreshLoop = null;
@ -274,6 +276,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
rangeToDisplay += 6;
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
updateGUI("rangeChange");
return false;
}
});
return view;
}
@ -1025,12 +1037,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - new Date().getTime()) / (60 * 60 * 1000));
predHours = Math.min(2, predHours);
predHours = Math.max(0, predHours);
hoursToFetch = (int) (6 - predHours);
hoursToFetch = (int) (rangeToDisplay - predHours);
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
endTime = toTime + predHours * 60 * 60 * 1000L;
} else {
hoursToFetch = 6;
hoursToFetch = rangeToDisplay;
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
endTime = toTime;