]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java
whitespace
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionModel.java
index bd2c640fd0ddfaa7b477f1287e6875c9f306b3e1..0198b8696a12de0c3cbe929baa3a64461d43c8da 100644 (file)
@@ -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<Boolean> 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<Boolean> editable = new MutableLiveData<>(true);
         private FocusedElement focusedElement = FocusedElement.Account;
+        private MutableLiveData<String> comment = new MutableLiveData<>(null);
+        private MutableLiveData<Boolean> 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<Boolean> observer) {
             editable.removeObserver(observer);
         }
+        public void observeCommentVisible(NewTransactionActivity activity,
+                                          Observer<Boolean> observer) {
+            commentVisible.observe(activity, observer);
+        }
+        public void stopObservingCommentVisible(Observer<Boolean> observer) {
+            commentVisible.removeObserver(observer);
+        }
+        public void observeComment(NewTransactionActivity activity,
+                                          Observer<String> observer) {
+            comment.observe(activity, observer);
+        }
+        public void stopObservingComment(Observer<String> observer) {
+            comment.removeObserver(observer);
+        }
+        public void setComment(String comment) {
+            getAccount().setComment(comment);
+            this.comment.postValue(comment);
+        }
     }
 }