From ba5500ffec0ae5d85e626d210ac2ced957f83bc7 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 24 Apr 2021 23:51:55 +0300 Subject: [PATCH] fix displayed transactions count the count wrongly included the UI elements like date delimiters and the heading row --- .../ktnx/mobileledger/async/TransactionAccumulator.java | 7 +++---- app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java | 4 ++-- 2 files changed, 5 insertions(+), 6 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 bdf4b7b1..1d86dbf6 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/TransactionAccumulator.java @@ -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); } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java index 4247e39f..a9488782 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java @@ -58,9 +58,9 @@ public class MainModel extends ViewModel { public LiveData> getDisplayedTransactions() { return displayedTransactions; } - public void setDisplayedTransactions(List list) { + public void setDisplayedTransactions(List list, int transactionCount) { displayedTransactions.postValue(list); - Data.lastUpdateTransactionCount.postValue(list.size()); + Data.lastUpdateTransactionCount.postValue(transactionCount); } public SimpleDate getFirstTransactionDate() { return firstTransactionDate; -- 2.39.5