From: Damyan Ivanov Date: Sat, 24 Apr 2021 20:51:55 +0000 (+0300) Subject: fix displayed transactions count X-Git-Tag: v0.18.0~24 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=ba5500ffec0ae5d85e626d210ac2ced957f83bc7;p=mobile-ledger.git fix displayed transactions count the count wrongly included the UI elements like date delimiters and the heading row --- 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;