tr = profile.loadTransaction(transactionId);
ArrayList<LedgerTransactionAccount> accounts = tr.getAccounts();
NewTransactionModel.Item firstNegative = null;
- boolean singleNegative = false;
+ NewTransactionModel.Item firstPositive = null;
+ int singleNegativeIndex = -1;
+ int singlePositiveIndex = -1;
int negativeCount = 0;
for (int i = 0; i < accounts.size(); i++) {
LedgerTransactionAccount acc = accounts.get(i);
if (acc.getAmount() < 0) {
if (firstNegative == null) {
firstNegative = item;
- singleNegative = true;
+ singleNegativeIndex = i;
}
else
- singleNegative = false;
+ singleNegativeIndex = -1;
+ }
+ else {
+ if (firstPositive == null) {
+ firstPositive = item;
+ singlePositiveIndex = i;
+ }
+ else
+ singlePositiveIndex = -1;
}
}
else
notifyItemChanged(i + 1);
}
- if (singleNegative) {
+ if (singleNegativeIndex != -1) {
firstNegative.getAccount()
.resetAmount();
+ model.moveItemLast(singleNegativeIndex);
+ }
+ else if (singlePositiveIndex != -1) {
+ firstPositive.getAccount()
+ .resetAmount();
+ model.moveItemLast(singlePositiveIndex);
}
}
model.checkTransactionSubmittable(this);
public void noteFocusIsOnComment(int position) {
model.noteFocusChanged(position, NewTransactionModel.FocusedElement.Comment);
}
+ public void toggleComment(int position) {
+ model.toggleComment(position);
+ }
}