Skip to content

Commit

Permalink
codinguser#876 - TransactionTypeSwitch does not change amount signum …
Browse files Browse the repository at this point in the history
…anymore
  • Loading branch information
JeanGarf committed Mar 7, 2020
1 parent 23790c8 commit c0bf48d
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@

/**
* A special type of {@link android.widget.ToggleButton} which displays the appropriate DEBIT/CREDIT labels for the
* linked account type
* linked account type and update the color of the amount and currency fields as well
*
* checked means CREDIT
* unchecked means DEBIT
*
* @author Ngewi Fet <[email protected]>
*/
// TODO TW m 2020-03-03 : Should be named SplitTypeToggleButton (or SplitTypeSwitch) instead of TransactionTypeSwitch
public class TransactionTypeSwitch extends SwitchCompat {

private AccountType mAccountType = AccountType.EXPENSE;
Expand Down Expand Up @@ -233,6 +232,21 @@ private void setSwitchTextAndColor(final boolean isCredit) {
: getTextOff() // DEBIT
);

//
// Change signum if needed
//

// BigDecimal amount = mAmountEditText.getValue();
//
// if (amount != null) {
// if ((isCredit && amount.signum() > 0) //we switched to debit but the amount is +ve
// || (!isCredit && amount.signum() < 0)) { //credit but amount is -ve
//
// mAmountEditText.setValue(amount.negate());
// }
//
// }

//
// Set text color of views
//
Expand Down Expand Up @@ -274,21 +288,6 @@ public void onCheckedChanged(CompoundButton compoundButton,

setSwitchTextAndColor(isCredit);

//
// Change signum if needed
//

BigDecimal amount = mAmountEditText.getValue();

if (amount != null) {
if ((isCredit && amount.signum() > 0) //we switched to debit but the amount is +ve
|| (!isCredit && amount.signum() < 0)) { //credit but amount is -ve

mAmountEditText.setValue(amount.negate());
}

}

//
// Call other listeners
//
Expand Down

0 comments on commit c0bf48d

Please sign in to comment.