From 2a0d9c329ac8163eee557dd72475d8f85ec372da Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 4 Apr 2019 17:52:53 +0300 Subject: [PATCH] LedgerAccount: fix NPE in getAmountCount() when there are no amounts triggered by empty accounts without amounts --- .../main/java/net/ktnx/mobileledger/model/LedgerAccount.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java index 0e2ae250..256be6f0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -119,7 +119,7 @@ public class LedgerAccount { public void addAmount(float amount) { this.addAmount(amount, null); } - public int getAmountCount() { return amounts.size(); } + public int getAmountCount() { return (amounts != null) ? amounts.size() : 0; } public String getAmountsString() { if ((amounts == null) || amounts.isEmpty()) return ""; @@ -193,4 +193,5 @@ public class LedgerAccount { public boolean amountsExpanded() { return amountsExpanded; } public void setAmountsExpanded(boolean flag) { amountsExpanded = flag; } public void toggleAmountsExpanded() { amountsExpanded = !amountsExpanded; } + } -- 2.39.5