Fix overshoot on last carb record.

This commit is contained in:
Johannes Mockenhaupt 2018-04-12 00:42:12 +02:00
parent 61cce65947
commit b1f66d086a
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -413,7 +413,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
if (smallCarbAmount == 0) smallCarbAmount = 1;
while (remainingCarbs > 0) {
createCarb(smallCarbAmount, carbTime);
createCarb(Math.min(smallCarbAmount, (long) remainingCarbs), carbTime);
remainingCarbs -= smallCarbAmount;
carbTime += 15 * 60 * 1000;
}