From: Damyan Ivanov Date: Thu, 4 Apr 2019 14:52:53 +0000 (+0300) Subject: LedgerAccount: fix NPE in getAmountCount() when there are no amounts X-Git-Tag: v0.9~2 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=2a0d9c329ac8163eee557dd72475d8f85ec372da;p=mobile-ledger.git LedgerAccount: fix NPE in getAmountCount() when there are no amounts triggered by empty accounts without amounts --- 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; } + }