PqAdapter.java
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.hh.xuetubao.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.PQbean;
import java.util.List;
public class PqAdapter extends RecyclerView.Adapter<PqAdapter.ViewHolder> {
private List<PQbean.RecordListBean> list;
private Context context;
public PqAdapter(List<PQbean.RecordListBean> list, Context context) {
this.list = list;
this.context = context;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.xrv_pq, null);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.total.setText(String.valueOf(list.get(position).getTotalPQCoin()));
if (list.get(position).getPaymentsType() != null) {
holder.label.setText(list.get(position).getPaymentsType());
if (list.get(position).getPaymentsType().equals("收入")) {
holder.change.setText("+" + String.valueOf(list.get(position).getIncoming()));
holder.label.setBackground(context.getResources().getDrawable(R.drawable.coners_green));
holder.tvPq.setTextColor(context.getResources().getColor(R.color.color_008f44));
holder.change.setTextColor(context.getResources().getColor(R.color.color_008f44));
} else {
holder.change.setText("-" + String.valueOf(list.get(position).getIncoming()));
holder.label.setBackground(context.getResources().getDrawable(R.drawable.coners_orange));
holder.tvPq.setTextColor(context.getResources().getColor(R.color.color_ff5400));
holder.change.setTextColor(context.getResources().getColor(R.color.color_ff5400));
}
}
if (list.get(position).getOperateName() != null)
holder.reason.setText(list.get(position).getOperateName());
if (list.get(position).getOperateTime() != null)
holder.time.setText(list.get(position).getOperateTime());
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final TextView label;
private final TextView total;
private final TextView time;
private final TextView change;
private final TextView reason;
private final TextView tvPq;
public ViewHolder(View itemView) {
super(itemView);
label = (TextView) itemView.findViewById(R.id.label);
reason = (TextView) itemView.findViewById(R.id.reason);
change = (TextView) itemView.findViewById(R.id.change);
time = (TextView) itemView.findViewById(R.id.time);
total = (TextView) itemView.findViewById(R.id.total);
tvPq = (TextView) itemView.findViewById(R.id.tv_pq);
}
}
}