X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionModel.java;h=03887c19410137857cc6eacbcc1c2e9673b8d47f;hb=6ca003394e24fb1b47cdaa2ca31679ec6da88af0;hp=7fd177683f461db1be543200007585a74dec4efb;hpb=356b7a4d11096b57996b0aaca854a8ef63d77670;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 7fd17768..03887c19 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 @@ -49,17 +49,19 @@ public class NewTransactionModel extends ViewModel { final MutableLiveData showCurrency = new MutableLiveData<>(false); final ArrayList items = new ArrayList<>(); final MutableLiveData isSubmittable = new MutableLiveData<>(false); + final MutableLiveData showComments = new MutableLiveData<>(true); private final Item header = new Item(this, null, ""); private final Item trailer = new Item(this); private final MutableLiveData focusedItem = new MutableLiveData<>(0); private final MutableLiveData accountCount = new MutableLiveData<>(0); private final MutableLiveData simulateSave = new MutableLiveData<>(false); - private boolean observingDataProfile; - private Observer profileObserver = - profile -> showCurrency.postValue(profile.getShowCommodityByDefault()); private final AtomicInteger busyCounter = new AtomicInteger(0); private final MutableLiveData busyFlag = new MutableLiveData<>(false); - final MutableLiveData showComments = new MutableLiveData<>(false); + private boolean observingDataProfile; + private Observer profileObserver = profile -> { + showCurrency.postValue(profile.getShowCommodityByDefault()); + showComments.postValue(profile.getShowCommentsByDefault()); + }; void observeShowComments(LifecycleOwner owner, Observer observer) { showComments.observe(owner, observer); } @@ -206,11 +208,13 @@ public class NewTransactionModel extends ViewModel { } void incrementBusyCounter() { int newValue = busyCounter.incrementAndGet(); - if (newValue == 1) busyFlag.postValue(true); + if (newValue == 1) + busyFlag.postValue(true); } void decrementBusyCounter() { int newValue = busyCounter.decrementAndGet(); - if (newValue == 0) busyFlag.postValue(false); + if (newValue == 0) + busyFlag.postValue(false); } public boolean getBusyFlag() { return busyFlag.getValue(); @@ -404,7 +408,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() {