Skip to content

Commit

Permalink
* codinguser#876 - Fix NPE when type switching on a new transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Yu committed May 29, 2020
1 parent f7a3fff commit 7ec717d
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,10 @@ private void setListeners() {
mTransactionTypeSwitch.setColorizeOnCheckedChangeListener();

mTransactionTypeSwitch.addOnCheckedChangeListener((buttonView, isChecked) -> {

// UI to Transaction
Transaction transaction = extractTransactionFromView();
// Compute balance signed value of saved transaction
final Money signedTransactionBalance = mTransaction.getBalance(mAccountUID);

final Money signedTransactionBalance = transaction.getBalance(mAccountUID);
// Update Amount Signum
updateAmountEditText(signedTransactionBalance);
});
Expand Down Expand Up @@ -985,7 +985,12 @@ String getTransferAccountUID() {
transaction.setNote(notes);
transaction.setSplits(splits);
transaction.setExported(false); //not necessary as exports use timestamps now. Because, legacy
if (mEditMode) {
// Editing an existing transaction

// reset the transaction UID
transaction.setUID(mTransaction.getUID());
}
return transaction;
}

Expand Down Expand Up @@ -1029,14 +1034,14 @@ private void saveNewTransaction() {
startTransferFunds();
return;
}
//
// UI to Transaction, with same UID if transaction edit mode
//
mTransaction = extractTransactionFromView();

Transaction transaction = extractTransactionFromView();

if (mEditMode) { //if editing an existing transaction
transaction.setUID(mTransaction.getUID());
}

mTransaction = transaction;
//
// Save transaction in DB
//
mAccountsDbAdapter.beginTransaction();

try {
Expand Down

0 comments on commit 7ec717d

Please sign in to comment.