]> git.ktnx.net Git - mobile-ledger.git/commitdiff
LedgerAccount: fix NPE in getAmountCount() when there are no amounts
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 4 Apr 2019 14:52:53 +0000 (17:52 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 4 Apr 2019 14:52:53 +0000 (17:52 +0300)
triggered by empty accounts without amounts

app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java

index 0e2ae2503539cca05c00a48f5fc3039d5e73dab9..256be6f082f7ee936f94943efde6782cf82386c3 100644 (file)
@@ -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; }
+
 }