From 44444c406faf8cab3542b05df60d2c837cdc4ca2 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 25 Jan 2020 16:07:42 +0200 Subject: [PATCH] more heuristics when filling accounts from a previous transaction previously, when there was a single account with negative amount, that amount was cleared from the row so that it is filled automatically when the amounts of other accounts change now this is also done for the single account with a positive amount if there is one, and there are multiple accounts with negative amounts --- .../activity/NewTransactionItemsAdapter.java | 18 ++++++++++-------- .../ui/activity/NewTransactionModel.java | 13 +++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java index 4d18db6a..710b4d68 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java @@ -228,8 +228,8 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter accounts = tr.getAccounts(); NewTransactionModel.Item firstNegative = null; NewTransactionModel.Item firstPositive = null; - boolean singleNegative = false; - boolean singlePositive = false; + int singleNegativeIndex = -1; + int singlePositiveIndex = -1; int negativeCount = 0; for (int i = 0; i < accounts.size(); i++) { LedgerTransactionAccount acc = accounts.get(i); @@ -248,18 +248,18 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter 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} //========================================================================================== -- 2.39.5