StudyTimeXrcAdapter.java
2.3 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
package com.hh.xuetubao.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
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.pieview.PColumn;
import java.text.DecimalFormat;
import java.util.List;
public class StudyTimeXrcAdapter extends RecyclerView.Adapter<StudyTimeXrcAdapter.ViewHolder> {
private Context context;
private List<String> day;
private List<String> time;
int max;
public StudyTimeXrcAdapter(Context context, List<String> day, List<String> time, int max) {
this.context = context;
this.day = day;
this.time = time;
this.max = max;
Log.e("maxValue1", "max" + max);
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.rc_read_time, null);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
int a = Integer.valueOf(day.get(position).substring(0, day.get(position).length() - 2));
if (day.get(position) != null) {
holder.tvDay.setText(time.get(position));
}
// if (time.get(position) != null) {
// holder.tvTime.setText(a + ""); //day.get(position)
// }
String format = new DecimalFormat("0").format(max * 1.2);
holder.pColumn.setData(a, Integer.valueOf(new DecimalFormat("0").format(max * 1.2)));
}
@Override
public int getItemCount() {
return day.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final TextView tvDay;
// private final TextView tvTime;
private final PColumn pColumn;
// private final View longView;
public ViewHolder(View itemView) {
super(itemView);
tvDay = (TextView) itemView.findViewById(R.id.tv_day);
// tvTime = (TextView) itemView.findViewById(R.id.tv_time);
pColumn = itemView.findViewById(R.id.pcolum);
// longView = itemView.findViewById(R.id.view_long);
}
}
}