]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix displayed transactions count
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 24 Apr 2021 20:51:55 +0000 (23:51 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 25 Apr 2021 17:07:58 +0000 (17:07 +0000)
the count wrongly included the UI elements like date delimiters and the
heading row

app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java
app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java

index bdf4b7b1e712c04401a95b7fdc7278183049c659..1d86dbf629028ca417f1eee8587c8e704230c25a 100644 (file)
@@ -29,7 +29,7 @@ public class TransactionAccumulator {
     private final String boldAccountName;
     private SimpleDate earliestDate, latestDate;
     private SimpleDate lastDate;
-    private boolean done;
+    private int transactionCount = 0;
     public TransactionAccumulator(String boldAccountName) {
         this.boldAccountName = boldAccountName;
 
@@ -39,8 +39,7 @@ public class TransactionAccumulator {
         put(transaction, transaction.getDate());
     }
     public void put(LedgerTransaction transaction, SimpleDate date) {
-        if (done)
-            throw new IllegalStateException("Can't put new items after done()");
+        transactionCount++;
 
         // first item
         if (null == latestDate)
@@ -59,7 +58,7 @@ public class TransactionAccumulator {
         lastDate = date;
     }
     public void publishResults(MainModel model) {
-        model.setDisplayedTransactions(list);
+        model.setDisplayedTransactions(list, transactionCount);
         model.setFirstTransactionDate(earliestDate);
         model.setLastTransactionDate(latestDate);
     }
index 4247e39fbd4f242b9726c80ec41f41b0c31946ee..a94887824d12dc324a90a3b2d843cd36f5a17956 100644 (file)
@@ -58,9 +58,9 @@ public class MainModel extends ViewModel {
     public LiveData<List<TransactionListItem>> getDisplayedTransactions() {
         return displayedTransactions;
     }
-    public void setDisplayedTransactions(List<TransactionListItem> list) {
+    public void setDisplayedTransactions(List<TransactionListItem> list, int transactionCount) {
         displayedTransactions.postValue(list);
-        Data.lastUpdateTransactionCount.postValue(list.size());
+        Data.lastUpdateTransactionCount.postValue(transactionCount);
     }
     public SimpleDate getFirstTransactionDate() {
         return firstTransactionDate;