Skip to content

Commit

Permalink
When predictions are enabled, only rescale the X axis when the time p…
Browse files Browse the repository at this point in the history
…eriod is not always locked; and if it is locked, center the display on the current bg value, not the last prediction.
  • Loading branch information
trallen committed May 15, 2024
1 parent db904ab commit b2bc51b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -2296,8 +2296,12 @@ private void setHoursViewPort(final String source) {
break;
}

float ideal_hours_to_show = DEFAULT_CHART_HOURS + bgGraphBuilder.getPredictivehours();
// always show at least the ideal number of hours if locked or auto
// always show at least the ideal number of hours
float ideal_hours_to_show = DEFAULT_CHART_HOURS;
// ... and rescale to accommodate predictions if not locked
if (! homeShelf.get("time_locked_always")) {
ideal_hours_to_show += bgGraphBuilder.getPredictivehours();
}
float hours_to_show = exactHoursSpecified ? hours : Math.max(hours, ideal_hours_to_show);

UserError.Log.d(TAG, "VIEWPORT " + source + " moveviewport in setHours: asked " + hours + " vs auto " + ideal_hours_to_show + " = " + hours_to_show + " full chart width: " + bgGraphBuilder.hoursShownOnChart());
Expand All @@ -2308,6 +2312,12 @@ private void setHoursViewPort(final String source) {
holdViewport.top = maxViewPort.top;
holdViewport.bottom = maxViewPort.bottom;

// if locked, center display on current bg values, not predictions
if (homeShelf.get("time_locked_always")) {
holdViewport.left -= hour_width * bgGraphBuilder.getPredictivehours();
holdViewport.right -= hour_width * bgGraphBuilder.getPredictivehours();
}

if (d) {
UserError.Log.d(TAG, "HOLD VIEWPORT " + holdViewport);
UserError.Log.d(TAG, "MAX VIEWPORT " + maxViewPort);
Expand Down

0 comments on commit b2bc51b

Please sign in to comment.