From 53675314b4bc3a1e4d535f2acb0c3f5704f0cd5e Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 16 May 2021 14:38:19 +0300 Subject: [PATCH] track more instances where currency may be null (and replace it with "") --- .../ktnx/mobileledger/model/LedgerTransactionAccount.java | 3 +++ .../ui/new_transaction/NewTransactionModel.java | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java index 774112ac..9706dbb5 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionAccount.java @@ -18,6 +18,7 @@ package net.ktnx.mobileledger.model; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.ktnx.mobileledger.db.TransactionAccount; import net.ktnx.mobileledger.utils.Misc; @@ -29,6 +30,7 @@ public class LedgerTransactionAccount { private String shortAccountName; private float amount; private boolean amountSet = false; + @Nullable private String currency; private String comment; private boolean amountValid = true; @@ -103,6 +105,7 @@ public class LedgerTransactionAccount { return amountSet; } public boolean isAmountValid() { return amountValid; } + @Nullable public String getCurrency() { return currency; } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java index b3e9eeb3..cfe9c5d9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java @@ -497,8 +497,8 @@ public class NewTransactionModel extends ViewModel { int negativeCount = 0; for (int i = 0; i < accounts.size(); i++) { LedgerTransactionAccount acc = accounts.get(i); - TransactionAccount item = - new TransactionAccount(acc.getAccountName(), acc.getCurrency()); + TransactionAccount item = new TransactionAccount(acc.getAccountName(), + Misc.nullIsEmpty(acc.getCurrency())); newList.add(item); item.setAccountName(acc.getAccountName()); @@ -1067,6 +1067,7 @@ public class NewTransactionModel extends ViewModel { private String accountName; private String amountHint; private String comment; + @NotNull private String currency = ""; private float amount; private boolean amountSet; @@ -1091,7 +1092,7 @@ public class NewTransactionModel extends ViewModel { } public TransactionAccount(LedgerTransactionAccount account) { super(); - currency = account.getCurrency(); + currency = Misc.nullIsEmpty(account.getCurrency()); amount = account.getAmount(); } public TransactionAccount(String accountName) { @@ -1175,6 +1176,7 @@ public class NewTransactionModel extends ViewModel { } @SuppressLint("DefaultLocale") @Override + @NotNull public String toString() { StringBuilder b = new StringBuilder(); b.append(String.format("id:%d/%s", id, Integer.toHexString(hashCode()))); -- 2.39.5