OneClickDeliveryReAdapter.java
4.7 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.HotJobBean;
import java.util.List;
public class OneClickDeliveryReAdapter extends RecyclerView.Adapter<OneClickDeliveryReAdapter.ViewHolder> {
private List<HotJobBean.JobListBean> list;
private Context context;
private boolean isSelectAll = false;
private String allJobId = "";
public OneClickDeliveryReAdapter(List<HotJobBean.JobListBean> 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.rv_oneclick_delivery, null);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
if (list.get(position).getJobName() != null)
holder.title.setText(list.get(position).getJobName());
if (list.get(position).getSalary() != null)
holder.money.setText(list.get(position).getSalary());
if (list.get(position).getExprience() != null)
holder.experience.setText(list.get(position).getExprience());
if (list.get(position).getEducation() != null)
holder.education.setText(list.get(position).getEducation());
if (isSelectAll) {
holder.select.setChecked(true);
if (list.size() > 1) {
for (int i = 0; i < list.size(); i++) {
if (allJobId == null) {
allJobId += list.get(position).getJobOid();
} else {
allJobId += ",";
allJobId += list.get(position).getJobOid();
}
}
selectJob.selectJobId(true, allJobId);
allJobId = "";
}
} else {
holder.select.setChecked(false);
selectJob.selectJobId(false, "");
}
holder.select.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
selectJob.selectJobId(true, list.get(position).getJobOid());
} else {
selectJob.selectJobId(false, list.get(position).getJobOid());
}
}
});
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (jumpToDetail != null) {
jumpToDetail.turnToDetail(list.get(position).getJobOid());
}
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final TextView title;
private final TextView money;
private final TextView company;
private final TextView experience;
private final TextView education;
private final TextView address;
private final CheckBox select;
public ViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.tv_title);
money = (TextView) itemView.findViewById(R.id.money);
company = (TextView) itemView.findViewById(R.id.tv_company);
experience = (TextView) itemView.findViewById(R.id.tv_experience);
education = (TextView) itemView.findViewById(R.id.tv_education);
address = (TextView) itemView.findViewById(R.id.tv_address);
select = (CheckBox) itemView.findViewById(R.id.select);
}
}
public void setSelectAll(boolean selectAll) {
isSelectAll = selectAll;
}
private selectJob selectJob;
public void setSelectJob(OneClickDeliveryReAdapter.selectJob selectJob) {
this.selectJob = selectJob;
}
public interface selectJob {
void selectJobId(boolean isAdd, String jobId);
}
private JumpToDetail jumpToDetail;
public void setJumpToDetail(JumpToDetail jumpToDetail) {
this.jumpToDetail = jumpToDetail;
}
public interface JumpToDetail {
void turnToDetail(String JobOid);
}
}