Skip to content

Commit

Permalink
codinguser#876 - Create setViewsToColorize(...) to initialize views t…
Browse files Browse the repository at this point in the history
…o colorize in red/green
  • Loading branch information
JeanGarf committed Mar 3, 2020
1 parent 02e6a02 commit e7f8d6f
Showing 1 changed file with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

/**
* A special type of {@link android.widget.ToggleButton} which displays the appropriate DEBIT/CREDIT labels for the
* different account types.
* linked account type
*
* checked means CREDIT
* unchecked means DEBIT
*
* @author Ngewi Fet <[email protected]>
*/
// TODO TW C 2020-03-03 : A renommer SplitTypeSwitch (AC)
Expand Down Expand Up @@ -69,6 +73,23 @@ public TransactionTypeSwitch(Context context) {
super(context);
}

/**
* Store views to colorize (green/red) accordingly to TransactionType and AccountType
* in addition to the current switch button
*
* @param amountEditText
* EditText displaying the amount value
*
* @param currencyTextView
* Currency symbol text view
*/
public void setViewsToColorize(CalculatorEditText amountEditText,
TextView currencyTextView) {

mAmountEditText = amountEditText;
mCurrencyTextView = currencyTextView;
}

/**
* Store the accountType
* and define switch on/off texts accordingly
Expand All @@ -77,7 +98,7 @@ public TransactionTypeSwitch(Context context) {
*/
public void setAccountType(AccountType accountType) {

this.mAccountType = accountType;
mAccountType = accountType;

Context context = getContext().getApplicationContext();

Expand Down Expand Up @@ -148,15 +169,10 @@ public void setAccountType(AccountType accountType) {
* Bind a ColorizeOnTransactionTypeChangeListener as a switch checked change listener
* to update the signum of amount view, colorize amount,
* currency and switch views accordingly
*
* @param amoutView Amount string {@link android.widget.EditText}
* @param currencyTextView Currency symbol text view
*/
public void setColorizeOnCheckedChangeListener(CalculatorEditText amoutView,
TextView currencyTextView) {
public void setColorizeOnCheckedChangeListener() {

setOnCheckedChangeListener(new ColorizeOnTransactionTypeChangeListener(amoutView,
currencyTextView));
setOnCheckedChangeListener(new ColorizeOnTransactionTypeChangeListener());
}

/**
Expand Down Expand Up @@ -260,13 +276,9 @@ private class ColorizeOnTransactionTypeChangeListener

/**
* Constructor with the amount view
* @param amountEditText EditText displaying the amount value
* @param currencyTextView Currency symbol text view
*/
public ColorizeOnTransactionTypeChangeListener(CalculatorEditText amountEditText, TextView currencyTextView){
public ColorizeOnTransactionTypeChangeListener(){

mAmountEditText = amountEditText;
mCurrencyTextView = currencyTextView;
}

@Override
Expand Down

0 comments on commit e7f8d6f

Please sign in to comment.