profile.markAccountsAsNotPresent(db);
AccountListParser parser = new AccountListParser(resp);
+ ArrayList<LedgerAccount> accountList = new ArrayList<>();
while (true) {
+ throwIfCancelled();
ParsedLedgerAccount parsedAccount = parser.nextAccount();
if (parsedAccount == null) break;
profile.storeAccountValue(acc.getName(), b.getAcommodity(),
b.getAquantity().asFloat());
}
+
+ accountList.add(acc);
}
+ throwIfCancelled();
profile.deleteNotPresentAccounts(db);
+ throwIfCancelled();
db.setTransactionSuccessful();
+ Data.accounts.set(accountList);
}
finally {
db.endTransaction();
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200)
throw new IOException(String.format("HTTP error %d", http.getResponseCode()));
+ throwIfCancelled();
db.beginTransaction();
try {
profile.markTransactionsAsNotPresent(db);
int processedTransactionCount = 0;
while (true) {
+ throwIfCancelled();
ParsedLedgerTransaction parsedTransaction = parser.nextTransaction();
+ throwIfCancelled();
if (parsedTransaction == null) break;
LedgerTransaction transaction = parsedTransaction.asLedgerTransaction();
if (transaction.existsInDb(db)) {
progress.setTotal(progress.getProgress());
publishProgress(progress);
db.setTransactionSuccessful();
+ profile.setLastUpdateStamp();
return true;
}
}
publishProgress(progress);
}
+ throwIfCancelled();
profile.deleteNotPresentTransactions(db);
+ throwIfCancelled();
db.setTransactionSuccessful();
+ profile.setLastUpdateStamp();
}
finally {
db.endTransaction();