X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionModel.java;h=83ffbb8f7bed90cdf747e60cc0daf6ef3d61e182;hb=a1f5cf187a6bc2731aa1ed057d3d11fccc5de2c4;hp=f5568081c6a88ba98e74f2a142c9864655a68334;hpb=ee3c0ffdb714b35759198466f955e2333fdd8c8b;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java index f5568081..83ffbb8f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java @@ -58,8 +58,10 @@ public class NewTransactionModel extends ViewModel { private final AtomicInteger busyCounter = new AtomicInteger(0); private final MutableLiveData busyFlag = new MutableLiveData<>(false); private boolean observingDataProfile; - private Observer profileObserver = - profile -> showCurrency.postValue(profile.getShowCommodityByDefault()); + private Observer profileObserver = profile -> { + showCurrency.postValue(profile.getShowCommodityByDefault()); + showComments.postValue(profile.getShowCommentsByDefault()); + }; void observeShowComments(LifecycleOwner owner, Observer observer) { showComments.observe(owner, observer); } @@ -239,6 +241,7 @@ public class NewTransactionModel extends ViewModel { private FocusedElement focusedElement = FocusedElement.Account; private MutableLiveData comment = new MutableLiveData<>(null); private MutableLiveData currency = new MutableLiveData<>(null); + private MutableLiveData amountValid = new MutableLiveData<>(true); private boolean amountHintIsSet = false; Item(NewTransactionModel model) { this.model = model; @@ -406,7 +409,6 @@ public class NewTransactionModel extends ViewModel { this.comment.observe(owner, observer); } void stopObservingTransactionComment(@NonNull Observer observer) { - ensureType(ItemType.generalData); this.comment.removeObserver(observer); } public LedgerTransactionAccount getAccount() { @@ -488,5 +490,17 @@ public class NewTransactionModel extends ViewModel { boolean isAmountHintSet() { return amountHintIsSet; } + void validateAmount() { + amountValid.setValue(true); + } + void invalidateAmount() { + amountValid.setValue(false); + } + void observeAmountValidity(NewTransactionActivity activity, Observer observer) { + amountValid.observe(activity, observer); + } + void stopObservingAmountValidity(Observer observer) { + amountValid.removeObserver(observer); + } } }