|
6 | 6 | import android.view.View; |
7 | 7 | import android.view.ViewGroup; |
8 | 8 | import android.widget.BaseAdapter; |
9 | | -import android.widget.TextView; |
10 | 9 |
|
11 | 10 | import com.blogspot.e_kanivets.moneytracker.MtApp; |
12 | | -import com.blogspot.e_kanivets.moneytracker.R; |
13 | 11 | import com.blogspot.e_kanivets.moneytracker.controller.FormatController; |
| 12 | +import com.blogspot.e_kanivets.moneytracker.databinding.ViewExchangeRateBinding; |
14 | 13 | import com.blogspot.e_kanivets.moneytracker.entity.ExchangeRatePair; |
15 | 14 |
|
16 | 15 | import java.util.List; |
17 | 16 |
|
18 | 17 | import javax.inject.Inject; |
19 | 18 |
|
20 | | -import butterknife.BindView; |
21 | | -import butterknife.ButterKnife; |
22 | | - |
23 | | -/** |
24 | | - * Custom adapter class for Exchange rate entity. |
25 | | - * Created on 23/2/16. |
26 | | - * |
27 | | - * @author Evgenii Kanivets |
28 | | - */ |
29 | 19 | public class ExchangeRateAdapter extends BaseAdapter { |
30 | 20 | @Inject |
31 | 21 | FormatController formatController; |
@@ -57,39 +47,26 @@ public long getItemId(int position) { |
57 | 47 | @SuppressLint("SetTextI18n") |
58 | 48 | @Override |
59 | 49 | public View getView(final int position, View convertView, ViewGroup parent) { |
60 | | - ViewHolder viewHolder; |
| 50 | + ViewExchangeRateBinding binding; |
61 | 51 |
|
62 | 52 | if (convertView == null) { |
63 | 53 | LayoutInflater layoutInflater = LayoutInflater.from(context); |
64 | 54 |
|
65 | | - convertView = layoutInflater.inflate(R.layout.view_exchange_rate, parent, false); |
66 | | - viewHolder = new ViewHolder(convertView); |
| 55 | + binding = ViewExchangeRateBinding.inflate(layoutInflater, parent, false); |
| 56 | + convertView = binding.getRoot(); |
67 | 57 |
|
68 | | - convertView.setTag(viewHolder); |
69 | | - } else viewHolder = (ViewHolder) convertView.getTag(); |
| 58 | + convertView.setTag(binding); |
| 59 | + } else { |
| 60 | + binding = (ViewExchangeRateBinding) convertView.getTag(); |
| 61 | + } |
70 | 62 |
|
71 | 63 | ExchangeRatePair rate = getItem(position); |
72 | 64 |
|
73 | | - viewHolder.tvFromCurrency.setText(rate.getFromCurrency()); |
74 | | - viewHolder.tvToCurrency.setText(rate.getToCurrency()); |
75 | | - viewHolder.tvAmountBuy.setText(formatController.formatPrecisionNone(rate.getAmountBuy())); |
76 | | - viewHolder.tvAmountSell.setText(formatController.formatPrecisionNone(rate.getAmountSell())); |
| 65 | + binding.tvFromCurrency.setText(rate.getFromCurrency()); |
| 66 | + binding.tvToCurrency.setText(rate.getToCurrency()); |
| 67 | + binding.tvAmountBuy.setText(formatController.formatPrecisionNone(rate.getAmountBuy())); |
| 68 | + binding.tvAmountSell.setText(formatController.formatPrecisionNone(rate.getAmountSell())); |
77 | 69 |
|
78 | 70 | return convertView; |
79 | 71 | } |
80 | | - |
81 | | - public static class ViewHolder { |
82 | | - @BindView(R.id.tv_from_currency) |
83 | | - TextView tvFromCurrency; |
84 | | - @BindView(R.id.tv_to_currency) |
85 | | - TextView tvToCurrency; |
86 | | - @BindView(R.id.tv_amount_buy) |
87 | | - TextView tvAmountBuy; |
88 | | - @BindView(R.id.tv_amount_sell) |
89 | | - TextView tvAmountSell; |
90 | | - |
91 | | - public ViewHolder(View view) { |
92 | | - ButterKnife.bind(this, view); |
93 | | - } |
94 | | - } |
95 | 72 | } |
0 commit comments