JobHuntCompanyAdapter.java
4.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
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
package com.hh.xuetubao.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.CompanyBean;
import java.util.List;
public class JobHuntCompanyAdapter extends RecyclerView.Adapter<JobHuntCompanyAdapter.ViewHolder> {
private Context context;
private List<CompanyBean.CompanyListBean> list;
public JobHuntCompanyAdapter(Context context, List<CompanyBean.CompanyListBean> list) {
this.context = context;
this.list = list;
}
@NonNull
@Override
public JobHuntCompanyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.rv_jobhunt_company, null);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull JobHuntCompanyAdapter.ViewHolder holder, final int position) {
holder.hotJobCount.setText(String.valueOf(list.get(position).getJobCount()));
List<CompanyBean.CompanyListBean.IndustryListBean> industryListBeans = list.get(position).getIndustryList();
ListLabelAdapter adapter = new ListLabelAdapter(industryListBeans, context);
LinearLayoutManager manager = new LinearLayoutManager(context);
manager.setOrientation(LinearLayoutManager.HORIZONTAL);
holder.label.setLayoutManager(manager);
holder.label.setAdapter(adapter);
if (list.get(position).getCompanyLogo() != null)
Glide.with(context).load(list.get(position).getCompanyLogo()).into(holder.img);
if (list.get(position).getCompanName() != null)
holder.companyName.setText(list.get(position).getCompanName());
if (list.get(position).getCompanySize() != null)
holder.count.setText(list.get(position).getCompanySize());
if (list.get(position).getPopularJobName() != null)
holder.hotJob.setText(list.get(position).getPopularJobName());
if (list.get(position).getCompanyNature() != null)
holder.nature.setText(list.get(position).getCompanyNature());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (turn != null) {
turn.turnTo(list.get(position).getCompanyOid());
}
}
});
holder.hotJob.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (turn != null) {
turn.turnToZw(list.get(position).getPopularJobOid());
}
}
});
}
@Override
public int getItemCount() {
if (list.size() > 3) {
return 3;
} else {
return list.size();
}
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final ImageView img;
private final TextView companyName;
private final TextView count;
private final TextView nature;
private final TextView hotJob;
private final TextView hotJobCount;
private final RecyclerView label;
public ViewHolder(View itemView) {
super(itemView);
img = (ImageView) itemView.findViewById(R.id.img);
companyName = (TextView) itemView.findViewById(R.id.tv_name);
count = (TextView) itemView.findViewById(R.id.tv_count);
nature = (TextView) itemView.findViewById(R.id.tv_nature);
hotJob = (TextView) itemView.findViewById(R.id.hot_job);
hotJobCount = (TextView) itemView.findViewById(R.id.hot_job_count);
label = (RecyclerView) itemView.findViewById(R.id.list_label);
}
}
private Turn turn;
public void setTurn(Turn turn) {
this.turn = turn;
}
public interface Turn {
void turnTo(String CompanyOid);
void turnToZw(String id);
}
}