]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java
NT: move item touch helper to the adapter
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionModel.java
index 39b9ac8ad60f09dd3b44eae84995870f9158ccf1..0801eb2ecbb4769ac5e740395d823a460ad84d04 100644 (file)
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
 
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
@@ -53,6 +54,21 @@ public class NewTransactionModel extends ViewModel {
     private final MutableLiveData<Boolean> isSubmittable = new MutableLiveData<>(false);
     private final MutableLiveData<Integer> focusedItem = new MutableLiveData<>(0);
     private final MutableLiveData<Integer> accountCount = new MutableLiveData<>(0);
+    private final MutableLiveData<Boolean> simulateSave = new MutableLiveData<>(false);
+    public boolean getSimulateSave() {
+        return simulateSave.getValue();
+    }
+    public void setSimulateSave(boolean simulateSave) {
+        this.simulateSave.setValue(simulateSave);
+    }
+    public void toggleSimulateSave() {
+        simulateSave.setValue(!simulateSave.getValue());
+    }
+    public void observeSimulateSave(@NonNull @NotNull androidx.lifecycle.LifecycleOwner owner,
+                                    @NonNull
+                                            androidx.lifecycle.Observer<? super Boolean> observer) {
+        this.simulateSave.observe(owner, observer);
+    }
     public int getAccountCount() {
         return items.size();
     }
@@ -283,6 +299,9 @@ public class NewTransactionModel extends ViewModel {
     public void noteFocusIsOnAmount(int position) {
         getItem(position).setFocusIsOnAmount(true);
     }
+    public void swapItems(int one, int two) {
+        Collections.swap(items, one-1, two-1);
+    }
     enum ItemType {generalData, transactionRow, bottomFiller}
 
     //==========================================================================================