X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FLedgerAccount.java;h=b0593f992c4b43d88369d36f1e8e7a07ddb07101;hp=f632bba94311d97485e6f98584776c9176095bd6;hb=83cac114e375728080194fb09758b49c50a8119b;hpb=c040f83305fb25dfe9a7c088683926b7d101c373 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 f632bba9..b0593f99 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -23,6 +23,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; public class LedgerAccount { static Pattern reHigherAccount = Pattern.compile("^[^:]+:"); @@ -48,6 +49,17 @@ public class LedgerAccount { this.amounts = new ArrayList(); this.addAmount(amount); } + @Override + public int hashCode() { + return name.hashCode(); + } + @Override + public boolean equals(@Nullable Object obj) { + if (obj == null) return false; + + return obj.getClass().equals(this.getClass()) && + name.equals(((LedgerAccount) obj).getName()); + } // an account is visible if: // - it is starred (not hidden by a star) // - and it has an expanded parent or is a top account @@ -56,9 +68,9 @@ public class LedgerAccount { if (level == 0) return true; - return isVisible(Data.accounts.get()); + return isVisible(Data.accounts); } - public boolean isVisible(ArrayList list) { + public boolean isVisible(List list) { for (LedgerAccount acc : list) { if (acc.isParentOf(this)) { if (!acc.isExpanded()) return false;