Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit e15edc9

Browse files
author
Evgenii Kanivets
committed
#81[30m]. Fix +0 summary expense issue.
1 parent caee1d1 commit e15edc9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/presenter/ShortSummaryPresenter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,26 @@ public void update(IRecordReport report, String currency, List<String> ratesNeed
6060
report.getPeriod().getFirstDay(), report.getPeriod().getLastDay()));
6161

6262
viewHolder.tvTotalIncome.setTextColor(report.getTotalIncome() >= 0 ? green : red);
63-
viewHolder.tvTotalIncome.setText(format(report.getTotalIncome(), report.getCurrency()));
63+
viewHolder.tvTotalIncome.setText(formatIncome(report.getTotalIncome(), report.getCurrency()));
6464

65-
viewHolder.tvTotalExpense.setTextColor(report.getTotalExpense() >= 0 ? green : red);
66-
viewHolder.tvTotalExpense.setText(format(report.getTotalExpense(), report.getCurrency()));
65+
viewHolder.tvTotalExpense.setTextColor(report.getTotalExpense() > 0 ? green : red);
66+
viewHolder.tvTotalExpense.setText(formatExpense(report.getTotalExpense(), report.getCurrency()));
6767

6868
viewHolder.tvTotal.setTextColor(report.getTotal() >= 0 ? green : red);
69-
viewHolder.tvTotal.setText(format(report.getTotal(), report.getCurrency()));
69+
viewHolder.tvTotal.setText(formatIncome(report.getTotal(), report.getCurrency()));
7070
}
7171
}
7272

73-
private String format(double amount, String currency) {
73+
private String formatIncome(double amount, String currency) {
7474
return (amount >= 0 ? "+ " : "- ") + String.format(Locale.getDefault(), "%.0f", Math.abs(amount))
7575
+ " " + currency;
7676
}
7777

78+
private String formatExpense(double amount, String currency) {
79+
return (amount > 0 ? "+ " : "- ") + String.format(Locale.getDefault(), "%.0f", Math.abs(amount))
80+
+ " " + currency;
81+
}
82+
7883
public static class ViewHolder {
7984
@Bind(R.id.tv_period)
8085
TextView tvPeriod;

0 commit comments

Comments
 (0)