From: Damyan Ivanov Date: Sat, 25 Jan 2020 14:07:42 +0000 (+0200) Subject: more heuristics when filling accounts from a previous transaction X-Git-Tag: v0.12.0~90 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=44444c406faf8cab3542b05df60d2c837cdc4ca2 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 --- 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} //==========================================================================================