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

Commit f894d8d

Browse files
author
Evgenii Kanivets
committed
#21[30m]. Display exchange rates in appropriate way.
1 parent a5c3179 commit f894d8d

File tree

4 files changed

+79
-20
lines changed

4 files changed

+79
-20
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import android.widget.TextView;
1010

1111
import com.blogspot.e_kanivets.moneytracker.R;
12-
import com.blogspot.e_kanivets.moneytracker.model.Account;
1312
import com.blogspot.e_kanivets.moneytracker.model.ExchangeRate;
1413

1514
import java.util.List;
@@ -55,25 +54,28 @@ public View getView(final int position, View convertView, ViewGroup parent) {
5554
if (convertView == null) {
5655
LayoutInflater layoutInflater = LayoutInflater.from(context);
5756

58-
convertView = layoutInflater.inflate(R.layout.view_account, parent, false);
57+
convertView = layoutInflater.inflate(R.layout.view_exchange_rate, parent, false);
5958
viewHolder = new ViewHolder(convertView);
6059

6160
convertView.setTag(viewHolder);
6261
} else viewHolder = (ViewHolder) convertView.getTag();
6362

6463
ExchangeRate rate = getItem(position);
6564

66-
viewHolder.tvTitle.setText(rate.getFromCurrency());
67-
viewHolder.tvCurSum.setText(rate.getToCurrency());
65+
viewHolder.tvFromCurrency.setText(rate.getFromCurrency());
66+
viewHolder.tvToCurrency.setText(rate.getToCurrency());
67+
viewHolder.tvAmount.setText(Double.toString(rate.getAmount()));
6868

6969
return convertView;
7070
}
7171

7272
public static class ViewHolder {
73-
@Bind(R.id.tv_title)
74-
TextView tvTitle;
75-
@Bind(R.id.tv_cur_sum)
76-
TextView tvCurSum;
73+
@Bind(R.id.tv_from_currency)
74+
TextView tvFromCurrency;
75+
@Bind(R.id.tv_to_currency)
76+
TextView tvToCurrency;
77+
@Bind(R.id.tv_amount)
78+
TextView tvAmount;
7779

7880
public ViewHolder(View view) {
7981
ButterKnife.bind(this, view);

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5-
android:orientation="horizontal">
5+
android:orientation="horizontal"
6+
android:paddingBottom="@dimen/half_margin"
7+
android:paddingLeft="@dimen/activity_horizontal_margin"
8+
android:paddingRight="@dimen/activity_horizontal_margin"
9+
android:paddingTop="@dimen/half_margin">
610

711
<TextView
12+
android:id="@+id/tv_title"
813
android:layout_width="match_parent"
914
android:layout_height="wrap_content"
10-
android:text="New Text"
11-
android:id="@+id/tv_title"
12-
android:textSize="18sp"
13-
android:layout_weight="1"
1415
android:layout_gravity="center_vertical|top"
15-
android:gravity="left"
16-
android:layout_marginLeft="10dp"
16+
android:layout_weight="1"
1717
android:background="@android:color/transparent"
18-
android:paddingBottom="5dp" />
18+
android:gravity="left"
19+
android:paddingBottom="5dp"
20+
android:text="New Text"
21+
android:textSize="18sp" />
1922

2023
<TextView
24+
android:id="@+id/tv_cur_sum"
2125
android:layout_width="match_parent"
2226
android:layout_height="wrap_content"
23-
android:text="New Text"
24-
android:id="@+id/tv_cur_sum"
25-
android:textSize="18sp"
2627
android:layout_weight="1.15"
2728
android:background="@android:color/transparent"
2829
android:gravity="right"
29-
android:layout_marginRight="10dp" />
30+
android:text="New Text"
31+
android:textSize="18sp" />
3032

3133
</LinearLayout>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:orientation="horizontal"
7+
android:paddingBottom="@dimen/half_margin"
8+
android:paddingLeft="@dimen/activity_horizontal_margin"
9+
android:paddingRight="@dimen/activity_horizontal_margin"
10+
android:paddingTop="@dimen/half_margin"
11+
tools:context="com.blogspot.e_kanivets.moneytracker.activity.AddExchangeRateActivity">
12+
13+
<TextView
14+
android:id="@+id/tv_from_currency"
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:layout_weight="1"
18+
android:gravity="center|right" />
19+
20+
<TextView
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:layout_weight="1"
24+
android:gravity="center"
25+
android:text="*" />
26+
27+
<TextView
28+
android:id="@+id/tv_amount"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:layout_weight="1"
32+
android:gravity="center"
33+
android:maxLines="1" />
34+
35+
<TextView
36+
android:layout_width="match_parent"
37+
android:layout_height="wrap_content"
38+
android:layout_weight="1"
39+
android:gravity="center"
40+
android:text="=" />
41+
42+
<TextView
43+
android:layout_width="wrap_content"
44+
android:layout_height="wrap_content"
45+
android:gravity="center"
46+
android:text="1" />
47+
48+
<TextView
49+
android:id="@+id/tv_to_currency"
50+
android:layout_width="match_parent"
51+
android:layout_height="wrap_content"
52+
android:layout_weight="1"
53+
android:gravity="center|left" />
54+
</LinearLayout>

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
<!-- Default screen margins, per the Android Design guidelines. -->
88
<dimen name="activity_horizontal_margin">16dp</dimen>
99
<dimen name="activity_vertical_margin">16dp</dimen>
10+
<dimen name="half_margin">8dp</dimen>
1011
</resources>

0 commit comments

Comments
 (0)