Saner types.

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

View file

@ -408,12 +408,12 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
if (duration == 0) { if (duration == 0) {
createCarb(carbsAfterConstraints, time); createCarb(carbsAfterConstraints, time);
} else { } else {
double remainingCarbs = carbsAfterConstraints; long remainingCarbs = carbsAfterConstraints;
long carbTime = time; long carbTime = time;
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(Math.min(smallCarbAmount, (long) remainingCarbs), carbTime); createCarb(Math.min(smallCarbAmount, remainingCarbs), carbTime);
remainingCarbs -= smallCarbAmount; remainingCarbs -= smallCarbAmount;
carbTime += 15 * 60 * 1000; carbTime += 15 * 60 * 1000;
} }