From 2af429db4d7969bb6304e51912b61efa7314a548 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 19 Sep 2020 17:55:28 +0300 Subject: [PATCH] final fix for the first date delimiter item --- .../mobileledger/async/TransactionAccumulator.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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)); } -- 2.39.5