]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java
rewrite update of transaction list from DB with Room
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / async / TransactionAccumulator.java
index e7d21ed202a0973a3ad95bbec797421f7a13a28c..eb8376f0fc91a70176e5ec7e3f30fbc5fdcbfd4d 100644 (file)
@@ -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
@@ -30,12 +30,14 @@ public class TransactionAccumulator {
     private SimpleDate earliestDate, latestDate;
     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) {
+        put(transaction, transaction.getDate());
+    }
     public void put(LedgerTransaction transaction, SimpleDate date) {
         if (done)
             throw new IllegalStateException("Can't put new items after done()");
@@ -55,11 +57,10 @@ public class TransactionAccumulator {
         list.add(new TransactionListItem(transaction));
 
         lastDate = date;
-        transactionCount++;
     }
     public void done() {
         done = true;
-        model.setDisplayedTransactions(list, transactionCount);
+        model.setDisplayedTransactions(list);
         model.setFirstTransactionDate(earliestDate);
         model.setLastTransactionDate(latestDate);
     }