]> git.ktnx.net Git - mobile-ledger.git/commitdiff
final fix for the first date delimiter item
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 19 Sep 2020 14:55:28 +0000 (17:55 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 19 Sep 2020 14:55:28 +0000 (17:55 +0300)
app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java

index a3358e085cf1c75942ee0942b54efcd1f79de523..e7d21ed202a0973a3ad95bbec797421f7a13a28c 100644 (file)
@@ -28,24 +28,26 @@ public class TransactionAccumulator {
     private final ArrayList<TransactionListItem> 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));
         }