From: Damyan Ivanov Date: Sat, 19 Sep 2020 14:55:28 +0000 (+0300) Subject: final fix for the first date delimiter item X-Git-Tag: v0.15.0~8 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=2af429db4d7969bb6304e51912b61efa7314a548;p=mobile-ledger.git final fix for the first date delimiter item --- 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..e7d21ed2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java @@ -28,24 +28,26 @@ public class TransactionAccumulator { private final ArrayList list = new ArrayList<>(); private final MainModel model; 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; + + list.add(new TransactionListItem()); // head item } 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)); }