public class TransactionAccumulator {
private final ArrayList<TransactionListItem> list = new ArrayList<>();
- private final MainModel model;
private final String boldAccountName;
private SimpleDate earliestDate, latestDate;
private SimpleDate lastDate;
private boolean done;
- public TransactionAccumulator(MainModel model) {
- this.model = model;
-
- boldAccountName = model.getAccountFilter()
- .getValue();
+ public TransactionAccumulator(String boldAccountName) {
+ this.boldAccountName = boldAccountName;
list.add(new TransactionListItem()); // head item
}
lastDate = date;
}
- public void done() {
- done = true;
+ public void publishResults(MainModel model) {
model.setDisplayedTransactions(list);
model.setFirstTransactionDate(earliestDate);
model.setLastTransactionDate(latestDate);
.getAllWithAccountsFilteredSync(profileId, accFilter);
}
- TransactionAccumulator accumulator = new TransactionAccumulator(model);
+ TransactionAccumulator accumulator = new TransactionAccumulator(accFilter);
for (TransactionWithAccounts tr : transactions) {
if (isCancelled())
accumulator.put(new LedgerTransaction(tr));
}
- accumulator.done();
+ accumulator.publishResults(model);
+
debug("UTT", "transaction list value updated");
return null;
String accNameFilter = model.getAccountFilter()
.getValue();
- TransactionAccumulator acc = new TransactionAccumulator(model);
+ TransactionAccumulator acc = new TransactionAccumulator(accNameFilter);
for (LedgerTransaction tr : list) {
if (isInterrupted()) {
return;
acc.put(tr, tr.getDate());
}
}
- if (!isInterrupted()) {
- acc.done();
- }
- Logger.debug("dFilter", "left synchronized block");
+
+ if (isInterrupted())
+ return;
+
+ acc.publishResults(model);
+ Logger.debug("dFilter", "transaction list updated");
}
}
}