Don't create empty future carbs records. Fixes #940.

When very few carbs are stretched out (e.g. 10g over 4h), there are
gaps, so that 1g is generated only every 30m. Don't create empty
records in between.
This commit is contained in:
Johannes Mockenhaupt 2018-05-01 12:22:01 +02:00
parent 73d7d98354
commit 8c3df40fdf
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -403,7 +403,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
long carbTime = time + i * 15 * 60 * 1000;
long smallCarbAmount = Math.round((1d * remainingCarbs) / (ticks-i)); //on last iteration (ticks-i) is 1 -> smallCarbAmount == remainingCarbs
remainingCarbs -= smallCarbAmount;
createCarb(smallCarbAmount, carbTime, notes);
if (smallCarbAmount > 0)
createCarb(smallCarbAmount, carbTime, notes);
}
}
}