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

Commit 3bb903e

Browse files
author
Evgenii Kanivets
committed
[30m]. Fix tests.
1 parent 90dc58f commit 3bb903e

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/adapter/AccountAdapter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.blogspot.e_kanivets.moneytracker.entity.Account;
1313

1414
import java.util.List;
15+
import java.util.Locale;
1516

1617
import butterknife.Bind;
1718
import butterknife.ButterKnife;
@@ -79,12 +80,16 @@ public View getView(final int position, View convertView, ViewGroup parent) {
7980
viewHolder.tvCurrency.setTextColor(account.getCurSum() >= 0 ? green : red);
8081

8182
viewHolder.tvTitle.setText(account.getTitle());
82-
viewHolder.tvCurSum.setText(Integer.toString(account.getCurSum()));
83+
viewHolder.tvCurSum.setText(format(account.getCurSum()));
8384
viewHolder.tvCurrency.setText(account.getCurrency());
8485

8586
return convertView;
8687
}
8788

89+
private String format(double amount) {
90+
return (amount >= 0 ? "+ " : "- ") + String.format(Locale.getDefault(), "%.0f", Math.abs(amount));
91+
}
92+
8893
public static class ViewHolder {
8994
@Bind(R.id.tv_title)
9095
TextView tvTitle;

app/src/main/java/com/blogspot/e_kanivets/moneytracker/ui/AccountsSummaryPresenter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,26 @@ public void update() {
103103
if (report == null) {
104104
viewHolder.tvTotal.setTextColor(red);
105105
viewHolder.tvTotal.setText(R.string.error_exchange_rates);
106+
viewHolder.tvCurrency.setText("");
106107
} else {
107108
viewHolder.tvTotal.setTextColor(report.getTotal() >= 0 ? green : red);
108-
viewHolder.tvTotal.setText(format(report.getTotal(), report.getCurrency()));
109+
viewHolder.tvTotal.setText(format(report.getTotal()));
110+
viewHolder.tvCurrency.setTextColor(report.getTotal() >= 0 ? green : red);
111+
viewHolder.tvCurrency.setText(report.getCurrency());
109112
}
110113
}
111114

112-
private String format(double amount, String currency) {
113-
return (amount >= 0 ? "+ " : "- ") + String.format(Locale.getDefault(), "%.0f", Math.abs(amount))
114-
+ " " + currency;
115+
private String format(double amount) {
116+
return (amount >= 0 ? "+ " : "- ") + String.format(Locale.getDefault(), "%.0f", Math.abs(amount));
115117
}
116118

117119
public static class ViewHolder {
118120
@Bind(R.id.spinner_currency)
119121
AppCompatSpinner spinnerCurrency;
120122
@Bind(R.id.tv_total)
121123
TextView tvTotal;
124+
@Bind(R.id.tv_currency)
125+
TextView tvCurrency;
122126

123127
public ViewHolder(View view) {
124128
ButterKnife.bind(this, view);

app/src/main/res/layout/view_summary_accounts.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,22 @@
4949

5050
<TextView
5151
android:id="@+id/tv_total"
52-
style="@style/Text_Body1"
5352
android:layout_width="wrap_content"
54-
android:layout_height="wrap_content" />
53+
android:layout_height="wrap_content"
54+
android:gravity="end"
55+
android:text="New Text"
56+
android:theme="@style/Text_Body2" />
57+
58+
<TextView
59+
android:id="@+id/tv_currency"
60+
android:layout_width="wrap_content"
61+
android:layout_height="wrap_content"
62+
android:fontFamily="monospace"
63+
android:gravity="end"
64+
android:paddingEnd="@dimen/zero_margin"
65+
android:paddingStart="5dp"
66+
android:text="New Text"
67+
android:theme="@style/Text_Body1" />
5568

5669
</LinearLayout>
5770

app/src/test/java/com/blogspot/e_kanivets/moneytracker/report/ReportTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,11 @@ public ExchangeRate getRate(@Nullable Record record) {
254254

255255
}
256256
}
257+
258+
@Nullable
259+
@Override
260+
public ExchangeRate getRate(@Nullable Account account) {
261+
return null;
262+
}
257263
}
258264
}

0 commit comments

Comments
 (0)