X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FCurrency.java;h=6933930b6834494c5bccaf96fd3972f0b93864b5;hb=c27aa72c2c641bcd568692b4a20b125605cfb3b5;hp=3cb70f8bd6cec7ea199a4d81f9bfdcf17828a4c2;hpb=0547f9d321932c2fa227eedd93eb4ba4f089706e;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Currency.java b/app/src/main/java/net/ktnx/mobileledger/model/Currency.java index 3cb70f8b..6933930b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Currency.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Currency.java @@ -24,6 +24,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.DiffUtil; import net.ktnx.mobileledger.App; +import net.ktnx.mobileledger.utils.Misc; public class Currency { public static final DiffUtil.ItemCallback DIFF_CALLBACK = @@ -80,9 +81,30 @@ public class Currency { this.hasGap = hasGap; } public static Currency loadByName(String name) { - MobileLedgerProfile profile = Data.profile.getValue(); + MobileLedgerProfile profile = Data.getProfile(); return profile.loadCurrencyByName(name); } + static public boolean equal(Currency left, Currency right) { + if (left == null) { + return right == null; + } + else + return left.equals(right); + } + static public boolean equal(Currency left, String right) { + right = Misc.emptyIsNull(right); + if (left == null) { + return right == null; + } + else { + String leftName = Misc.emptyIsNull(left.getName()); + if (leftName == null) { + return right == null; + } + else + return leftName.equals(right); + } + } public int getId() { return id; }