Fix overshoot on last carb record.
This commit is contained in:
parent
61cce65947
commit
b1f66d086a
1 changed files with 1 additions and 1 deletions
|
@ -413,7 +413,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
|
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
|
||||||
if (smallCarbAmount == 0) smallCarbAmount = 1;
|
if (smallCarbAmount == 0) smallCarbAmount = 1;
|
||||||
while (remainingCarbs > 0) {
|
while (remainingCarbs > 0) {
|
||||||
createCarb(smallCarbAmount, carbTime);
|
createCarb(Math.min(smallCarbAmount, (long) remainingCarbs), carbTime);
|
||||||
remainingCarbs -= smallCarbAmount;
|
remainingCarbs -= smallCarbAmount;
|
||||||
carbTime += 15 * 60 * 1000;
|
carbTime += 15 * 60 * 1000;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue