X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FTransactionAccumulator.java;h=46b8426abbae7aaf1b16b91fd975ed87af52640b;hb=0b96f4968cd5c0b36474b94b94ec6dcf6699f60c;hp=a3358e085cf1c75942ee0942b54efcd1f79de523;hpb=f91a802798fea96f8296cdeed656221b1bdcf401;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java b/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java index a3358e08..46b8426a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java @@ -1,5 +1,5 @@ /* - * Copyright © 2020 Damyan Ivanov. + * Copyright © 2021 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -27,37 +27,44 @@ import java.util.ArrayList; public class TransactionAccumulator { private final ArrayList list = new ArrayList<>(); private final MainModel model; + private final String boldAccountName; private SimpleDate earliestDate, latestDate; - private SimpleDate lastDate = SimpleDate.today(); + private SimpleDate lastDate; private boolean done; - private int transactionCount = 0; public TransactionAccumulator(MainModel model) { this.model = model; + + boldAccountName = model.getAccountFilter() + .getValue(); + + list.add(new TransactionListItem()); // head item + } + public void put(LedgerTransaction transaction) { + put(transaction, transaction.getDate()); } public void put(LedgerTransaction transaction, SimpleDate date) { if (done) throw new IllegalStateException("Can't put new items after done()"); // first item - if (null == latestDate) { - list.add(new TransactionListItem()); + if (null == latestDate) latestDate = date; - } earliestDate = date; if (!date.equals(lastDate)) { + if (lastDate == null) + lastDate = SimpleDate.today(); boolean showMonth = date.month != lastDate.month || date.year != lastDate.year; list.add(new TransactionListItem(date, showMonth)); } - list.add(new TransactionListItem(transaction)); + list.add(new TransactionListItem(transaction, boldAccountName)); lastDate = date; - transactionCount++; } public void done() { done = true; - model.setDisplayedTransactions(list, transactionCount); + model.setDisplayedTransactions(list); model.setFirstTransactionDate(earliestDate); model.setLastTransactionDate(latestDate); }