Skip to content

Commit

Permalink
codinguser#876 - Add shallDisplayAbsValue parameter in displayBalance…
Browse files Browse the repository at this point in the history
…(...)
  • Loading branch information
JeanGarf committed Mar 7, 2020
1 parent e9ab836 commit 23790c8
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/src/main/java/org/gnucash/android/model/AccountType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,28 @@ public enum AccountType {
}

AccountType() {

this(TransactionType.CREDIT);
}

/**
* Display the balance of a transaction in a text view and format the text color to match the sign of the amount
*
* @param balanceTextView {@link android.widget.TextView} where balance is to be displayed
* @param balance {@link org.gnucash.android.model.Money} balance (>0 or <0) to display
*/
public void displayBalance(final TextView balanceTextView,
final Money balance) {
final Money balance,
final boolean shallDisplayAbsValue) {

//
// Display amount
//

// TODO TW C 2020-03-06 : Déterminer qui doit dire s'il faut afficher un nombre négatif ou sa valeur absolue
balanceTextView.setText(balance.formattedString());
balanceTextView.setText(shallDisplayAbsValue
? balance.abs()
.formattedString()
: balance.formattedString());

//
// Define amount color
Expand Down Expand Up @@ -103,6 +108,21 @@ public void displayBalance(final TextView balanceTextView,
balanceTextView.setTextColor(fontColor);
}

/**
* Display the balance of a transaction in a text view and format the text color to match the sign of the amount
*
* @param balanceTextView
* {@link android.widget.TextView} where balance is to be displayed
* @param balance
* {@link org.gnucash.android.model.Money} balance (>0 or <0) to display
*/
public void displayBalance(final TextView balanceTextView,
final Money balance) {

displayBalance(balanceTextView,
balance,
false);
}
/**
* Compute red/green color according to accountType and isCreditAmount
*
Expand Down

0 comments on commit 23790c8

Please sign in to comment.