Skip to content

Commit

Permalink
codinguser#876 - Use setViewsToColorize(...) to initialize views to c…
Browse files Browse the repository at this point in the history
…olorize in red/green
  • Loading branch information
JeanGarf committed Mar 3, 2020
1 parent e7f8d6f commit f507e59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.gnucash.android.ui.common.FormActivity;
import org.gnucash.android.ui.common.UxArgument;
import org.gnucash.android.ui.transaction.dialog.TransferFundsDialogFragment;
import org.gnucash.android.ui.util.AccountUtils;
import org.gnucash.android.ui.util.widget.CalculatorEditText;
import org.gnucash.android.ui.util.widget.CalculatorKeyboard;
import org.gnucash.android.ui.util.widget.TransactionTypeSwitch;
Expand Down Expand Up @@ -430,8 +429,7 @@ public void onClick(View view) {
//

// Set a ColorizeOnTransactionTypeChange listener
splitTypeSwitch.setColorizeOnCheckedChangeListener(splitAmountEditText,
splitCurrencyTextView);
splitTypeSwitch.setColorizeOnCheckedChangeListener();

splitTypeSwitch.addOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand All @@ -449,6 +447,9 @@ private void initViews(final Split split) {
// splitTypeSwitch
//

splitTypeSwitch.setViewsToColorize(splitAmountEditText,
splitCurrencyTextView);

// TODO TW C 2020-03-03 : A enlever ou mettre dans un else ?
// Switch on/off according to amount signum
splitTypeSwitch.setChecked(mBaseAmount.signum() > 0);
Expand Down Expand Up @@ -651,8 +652,11 @@ private class SplitTransferAccountSelectedListener
public SplitTransferAccountSelectedListener(TransactionTypeSwitch typeToggleButton,
SplitViewHolder viewHolder) {

this.mTypeToggleButton = typeToggleButton;
this.mSplitViewHolder = viewHolder;

this.mTypeToggleButton = typeToggleButton;
this.mTypeToggleButton.setViewsToColorize(mSplitViewHolder.splitAmountEditText,
mSplitViewHolder.splitCurrencyTextView);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ private void initializeViewsWithTransaction(){
mDescriptionEditText.setText(mTransaction.getDescription());
mDescriptionEditText.setSelection(mDescriptionEditText.getText().length());

mTransactionTypeSwitch.setViewsToColorize(mAmountEditText,
mCurrencyTextView);

mTransactionTypeSwitch.setAccountType(mAccountType);
mTransactionTypeSwitch.setChecked(mTransaction.getBalance(mAccountUID).isNegative());

Expand Down Expand Up @@ -552,7 +555,11 @@ private void initalizeViews() {
mTimeTextView.setText(TIME_FORMATTER.format(time));
mTime = mDate = Calendar.getInstance();

mTransactionTypeSwitch.setViewsToColorize(mAmountEditText,
mCurrencyTextView);

mTransactionTypeSwitch.setAccountType(mAccountType);

String typePref = PreferenceActivity.getActiveBookSharedPreferences().getString(getString(R.string.key_default_transaction_type), "DEBIT");
mTransactionTypeSwitch.setChecked(TransactionType.valueOf(typePref));

Expand Down Expand Up @@ -663,8 +670,7 @@ private void openSplitEditor() {
*/
private void setListeners() {

mTransactionTypeSwitch.setColorizeOnCheckedChangeListener(mAmountEditText,
mCurrencyTextView);
mTransactionTypeSwitch.setColorizeOnCheckedChangeListener();

mDateTextView.setOnClickListener(new View.OnClickListener() {

Expand Down

0 comments on commit f507e59

Please sign in to comment.