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;fp=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FLedgerAccount.java;h=3bc01d1fecd852cc957aeb205640465dec80320f;hp=7510576a81a65fdd31792158514f40c474f8c8ef;hb=d58f8f4a9edd8b96005d1900c51b589471424165;hpb=b54a11eca1e4d0a03a3076047dc77f68666d4338 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 7510576a..3bc01d1f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -20,6 +20,7 @@ package net.ktnx.mobileledger.model; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -36,17 +37,23 @@ public class LedgerAccount { private List amounts; private boolean hasSubAccounts; private boolean amountsExpanded; + private WeakReference profileWeakReference; - public LedgerAccount(String name) { + public LedgerAccount(MobileLedgerProfile profile, String name) { + this.profileWeakReference = new WeakReference<>(profile); this.setName(name); } - public LedgerAccount(String name, float amount) { + public LedgerAccount(MobileLedgerProfile profile, String name, float amount) { + this.profileWeakReference = new WeakReference<>(profile); this.setName(name); this.expanded = true; this.amounts = new ArrayList(); this.addAmount(amount); } + public @Nullable MobileLedgerProfile getProfile() { + return profileWeakReference.get(); + } @Override public int hashCode() { return name.hashCode();