]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java
more heuristics when filling accounts from a previous transaction
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionModel.java
index 6dd640f9d8d22d505811f309dc0bd1b733979488..5bc327a78329ffcb6c2ca3b0570d0de13d581b8f 100644 (file)
@@ -298,12 +298,25 @@ 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());
     }
+    public void moveItemLast(int index) {
+        /*   0
+             1   <-- index
+             2
+             3   <-- desired position
+         */
+        int itemCount = items.size();
+
+        if (index < itemCount - 1) {
+            Item acc = items.remove(index);
+            items.add(itemCount - 1, acc);
+        }
+    }
     enum ItemType {generalData, transactionRow, bottomFiller}
 
     //==========================================================================================