OfficeDetailJobAdapter.java
3.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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.OfficeDetailBean;
import java.util.List;
public class OfficeDetailJobAdapter extends RecyclerView.Adapter<OfficeDetailJobAdapter.ViewHolder> {
private List<OfficeDetailBean.SimiliarJobListBean> list;
private Context context;
public OfficeDetailJobAdapter(List<OfficeDetailBean.SimiliarJobListBean> 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_recruiment_job, 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.job.setText(list.get(position).getJobName());
if (list.get(position).getSalary() != null)
holder.money.setText(list.get(position).getSalary());
if (list.get(position).getAddress() != null)
holder.address.setText(list.get(position).getAddress());
if (list.get(position).getExprience() != null)
holder.year.setText(list.get(position).getExprience());
if (list.get(position).getEducation() != null)
holder.education.setText(list.get(position).getEducation());
if (position == list.size() - 1) {
holder.line.setVisibility(View.GONE);
} else {
holder.line.setVisibility(View.VISIBLE);
}
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 job;
private final TextView money;
private final TextView year;
private final TextView education;
private final TextView address;
private final RecyclerView recLabel;
private final View line;
public ViewHolder(View itemView) {
super(itemView);
job = (TextView) itemView.findViewById(R.id.job);
money = (TextView) itemView.findViewById(R.id.money);
year = (TextView) itemView.findViewById(R.id.year);
education = (TextView) itemView.findViewById(R.id.education);
address = (TextView) itemView.findViewById(R.id.address);
recLabel = (RecyclerView) itemView.findViewById(R.id.rec_label);
line = itemView.findViewById(R.id.line);
}
}
private JumpToDetail jumpToDetail;
public void setJumpToDetail(JumpToDetail jumpToDetail) {
this.jumpToDetail = jumpToDetail;
}
public interface JumpToDetail {
void turnToDetail(String JobOid);
}
}