JobHuntFragment.java
7.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package com.hh.xuetubao.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
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.LinearLayout;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.RecyclerViewSpacesItemDecoration;
import com.hh.xuetubao.activity.personal.DeliveryActivity;
import com.hh.xuetubao.activity.work.CompanyActivity;
import com.hh.xuetubao.activity.work.CompanyDetailActivity;
import com.hh.xuetubao.activity.work.JobHuntActivity;
import com.hh.xuetubao.activity.work.OfficeDetailActivity;
import com.hh.xuetubao.adapter.JobHuntCompanyAdapter;
import com.hh.xuetubao.adapter.JobHuntWorkAdapter;
import com.hh.xuetubao.bean.CompanyBean;
import com.hh.xuetubao.bean.HotJobBean;
import com.hh.xuetubao.model.ZhaopinModel;
import com.hh.xuetubao.mvp.BaseMvpFragment;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* 求职圈
*/
public class JobHuntFragment extends BaseMvpFragment<CommonPresenter, ZhaopinModel> implements ICommonView, View.OnClickListener, JobHuntCompanyAdapter.Turn, JobHuntWorkAdapter.JumpToDetail {
Unbinder unbinder;
@BindView(R.id.rv_company)
RecyclerView rvCompany;
@BindView(R.id.rv_work)
RecyclerView rvWork;
@BindView(R.id.lin_more_company)
LinearLayout linMoreCompany;
@BindView(R.id.zhiwei_more)
LinearLayout zhiweiMore;
@BindView(R.id.img_zhiwei)
ImageView imgZhiwei;
@BindView(R.id.img_company)
ImageView imgCompany;
@BindView(R.id.image_tdjl)
ImageView imageTdjl;
private JobHuntCompanyAdapter adapter;
private JobHuntWorkAdapter workAdapter;
private List<CompanyBean.CompanyListBean> companyList = new ArrayList<>();
private List<HotJobBean.JobListBean> jobList = new ArrayList<>();
// private OfficeFragment officeFragment;
// private FragmentTransaction transaction;
private Intent intent;
@Override
public int getLayoutId() {
return R.layout.fragment_job_hunt;
}
@Override
public void initView(@Nullable Bundle savedInstanceState) {
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
manager.setOrientation(LinearLayoutManager.HORIZONTAL);
rvCompany.setLayoutManager(manager);
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, 20);//右间距
rvCompany.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));
adapter = new JobHuntCompanyAdapter(getActivity(), companyList);
rvCompany.setAdapter(adapter);
adapter.setTurn(this);
LinearLayoutManager manager1 = new LinearLayoutManager(getActivity());
rvWork.setLayoutManager(manager1);
workAdapter = new JobHuntWorkAdapter(getActivity(), jobList);
rvWork.setAdapter(workAdapter);
workAdapter.setJumpToDetail(this);
rvWork.setNestedScrollingEnabled(false);
linMoreCompany.setOnClickListener(this);
zhiweiMore.setOnClickListener(this);
imgZhiwei.setOnClickListener(this);
imgCompany.setOnClickListener(this);
imageTdjl.setOnClickListener(this);
}
@Override
public void initData() {
ZhaopinModel model = new ZhaopinModel();
model.getModel(this, 3, 1, String.valueOf(10));
model.getModel(this, 3, 2, String.valueOf(10));
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ZhaopinModel getModel() {
return new ZhaopinModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 3 && intent == 1) {
CompanyBean bean = (CompanyBean) o;
List<CompanyBean.CompanyListBean> companyListBeans = bean.getCompanyList();
companyList.addAll(companyListBeans);
adapter.notifyDataSetChanged();
if (companyList.size() > 3) {
linMoreCompany.setVisibility(View.VISIBLE);
} else {
linMoreCompany.setVisibility(View.GONE);
}
}
if (api == 3 && intent == 2) {
HotJobBean bean = (HotJobBean) o;
List<HotJobBean.JobListBean> beanJobList = bean.getJobList();
jobList.addAll(beanJobList);
workAdapter.notifyDataSetChanged();
if (jobList.size() > 3) {
zhiweiMore.setVisibility(View.VISIBLE);
} else {
zhiweiMore.setVisibility(View.GONE);
}
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO: inflate a fragment view
View rootView = super.onCreateView(inflater, container, savedInstanceState);
unbinder = ButterKnife.bind(this, rootView);
return rootView;
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.img_company: // 顶部公司
case R.id.lin_more_company:
startActivity(new Intent(getActivity(), CompanyActivity.class));
break;
case R.id.zhiwei_more:
case R.id.img_zhiwei:
Intent intent1 = new Intent(getActivity(), JobHuntActivity.class);
intent1.putExtra("jobTag", "1");
startActivity(intent1);
getActivity().finish();
// transaction = getActivity().getSupportFragmentManager().beginTransaction();
// officeFragment = new OfficeFragment();
// transaction.replace(R.id.frame, officeFragment);
// transaction.commit();
break;
case R.id.image_tdjl: // 投递记录
Intent intent = new Intent(getActivity(), DeliveryActivity.class);
startActivity(intent);
break;
}
}
@Override
public void turnTo(String CompanyOid) {
intent = new Intent(getActivity(), CompanyDetailActivity.class);
intent.putExtra("CompanyOid", CompanyOid);
startActivity(intent);
}
// 职位id
@Override
public void turnToZw(String id) {
intent = new Intent(getActivity(), OfficeDetailActivity.class);
intent.putExtra("JobOid", id);
startActivity(intent);
}
@Override
public void turnToDetail(String JobOid) {
intent = new Intent(getActivity(), OfficeDetailActivity.class);
intent.putExtra("JobOid", JobOid);
startActivity(intent);
}
}