ReadQuickInfoCommand: only read as many boluses as are available.

(cherry picked from commit 7857abb)
This commit is contained in:
Johannes Mockenhaupt 2018-02-03 22:00:56 +01:00
parent 183edfcc09
commit 2a5c28cf6b
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -36,14 +36,20 @@ public class ReadQuickInfoCommand extends BaseCommand {
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_DATA);
List<Bolus> bolusHistory = new ArrayList<>(numberOfBolusRecordsToRetrieve);
result.history = new PumpHistory().bolusHistory(bolusHistory);
for(int recordsLeftToRead = numberOfBolusRecordsToRetrieve; recordsLeftToRead > 0; recordsLeftToRead--) {
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_DATA);
bolusHistory.add(readBolusRecord());
// read bolus records
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
int record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
while (true) {
bolusHistory.add(readBolusRecord());
if (bolusHistory.size() == numberOfBolusRecordsToRetrieve || record == totalRecords) {
break;
}
// advance to next record
scripter.pressDownKey();
while (record == (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD)) {
scripter.waitForScreenUpdate();
}
record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
}
if (log.isDebugEnabled()) {
if (!result.history.bolusHistory.isEmpty()) {