Merge pull request #947 from jotomo/issue-940

Don't create empty future carbs records. Fixes #940.
This commit is contained in:
Milos Kozak 2018-05-01 20:07:46 +02:00 committed by GitHub
commit eb7b67781c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

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

View file

@ -76,7 +76,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER) if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only expected = 1; // VirtualPump only
else else
expected = 6; expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsList(PluginType.PUMP).size()); Assert.assertEquals(expected, mainApp.getSpecificPluginsList(PluginType.PUMP).size());
} }
@ -87,7 +87,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER) if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only expected = 1; // VirtualPump only
else else
expected = 6; expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size()); Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size());
} }
@ -98,7 +98,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER) if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only expected = 1; // VirtualPump only
else else
expected = 6; expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsListByInterface(PumpInterface.class).size()); Assert.assertEquals(expected, mainApp.getSpecificPluginsListByInterface(PumpInterface.class).size());
} }
@ -109,7 +109,7 @@ public class MainAppTest {
if (Config.NSCLIENT || Config.G5UPLOADER) if (Config.NSCLIENT || Config.G5UPLOADER)
expected = 1; // VirtualPump only expected = 1; // VirtualPump only
else else
expected = 6; expected = 7;
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInListByInterface(PumpInterface.class, PluginType.PUMP).size()); Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInListByInterface(PumpInterface.class, PluginType.PUMP).size());
} }