X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionModel.java;h=0198b8696a12de0c3cbe929baa3a64461d43c8da;hb=18bc95ab692b0073bd1f2766850e8fc0841b8a9d;hp=bd2c640fd0ddfaa7b477f1287e6875c9f306b3e1;hpb=7ae5407090d9ffe2026775ba9e569014f879b54d;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 bd2c640f..0198b869 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 @@ -298,7 +298,11 @@ public class NewTransactionModel extends ViewModel { getItem(position).setFocusedElement(element); } public void swapItems(int one, int two) { - Collections.swap(items, one-1, two-1); + Collections.swap(items, one - 1, two - 1); + } + public void toggleComment(int position) { + final MutableLiveData commentVisible = getItem(position).commentVisible; + commentVisible.postValue(!commentVisible.getValue()); } enum ItemType {generalData, transactionRow, bottomFiller} @@ -315,6 +319,8 @@ public class NewTransactionModel extends ViewModel { private NewTransactionModel model; private MutableLiveData editable = new MutableLiveData<>(true); private FocusedElement focusedElement = FocusedElement.Account; + private MutableLiveData comment = new MutableLiveData<>(null); + private MutableLiveData commentVisible = new MutableLiveData<>(false); public Item(NewTransactionModel model) { this.model = model; type = ItemType.bottomFiller; @@ -506,5 +512,23 @@ public class NewTransactionModel extends ViewModel { public void stopObservingEditableFlag(Observer observer) { editable.removeObserver(observer); } + public void observeCommentVisible(NewTransactionActivity activity, + Observer observer) { + commentVisible.observe(activity, observer); + } + public void stopObservingCommentVisible(Observer observer) { + commentVisible.removeObserver(observer); + } + public void observeComment(NewTransactionActivity activity, + Observer observer) { + comment.observe(activity, observer); + } + public void stopObservingComment(Observer observer) { + comment.removeObserver(observer); + } + public void setComment(String comment) { + getAccount().setComment(comment); + this.comment.postValue(comment); + } } }