Commit c7efa417930403d279c8fb910e39726740d7cac6
1 parent
7f9411e7f2
Exists in
master
避免空指针
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
app/src/main/java/com/hjx/parent/ErrorListActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
4 | import android.content.DialogInterface; | 4 | import android.content.DialogInterface; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
8 | import android.graphics.Color; | 8 | import android.graphics.Color; |
9 | import android.graphics.drawable.Drawable; | 9 | import android.graphics.drawable.Drawable; |
10 | import android.net.Uri; | 10 | import android.net.Uri; |
11 | import android.os.Bundle; | 11 | import android.os.Bundle; |
12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
14 | import android.util.Log; | 14 | import android.util.Log; |
15 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
16 | import android.view.LayoutInflater; | 16 | import android.view.LayoutInflater; |
17 | import android.view.View; | 17 | import android.view.View; |
18 | import android.widget.CompoundButton; | 18 | import android.widget.CompoundButton; |
19 | import android.widget.RadioButton; | 19 | import android.widget.RadioButton; |
20 | import android.widget.RadioGroup; | 20 | import android.widget.RadioGroup; |
21 | import android.widget.TextView; | 21 | import android.widget.TextView; |
22 | import android.widget.Toast; | 22 | import android.widget.Toast; |
23 | 23 | ||
24 | import androidx.annotation.Nullable; | 24 | import androidx.annotation.Nullable; |
25 | import androidx.core.content.FileProvider; | 25 | import androidx.core.content.FileProvider; |
26 | import androidx.recyclerview.widget.GridLayoutManager; | 26 | import androidx.recyclerview.widget.GridLayoutManager; |
27 | import androidx.recyclerview.widget.LinearLayoutManager; | 27 | import androidx.recyclerview.widget.LinearLayoutManager; |
28 | import androidx.recyclerview.widget.RecyclerView; | 28 | import androidx.recyclerview.widget.RecyclerView; |
29 | 29 | ||
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.adapter.ErrorAdapter; | 34 | import com.hjx.parent.adapter.ErrorAdapter; |
35 | import com.hjx.parent.adapter.FilterAdapter; | 35 | import com.hjx.parent.adapter.FilterAdapter; |
36 | import com.hjx.parent.adapter.GradeAdapter; | 36 | import com.hjx.parent.adapter.GradeAdapter; |
37 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; | 37 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; |
38 | import com.hjx.parent.bean.StudentBean; | 38 | import com.hjx.parent.bean.StudentBean; |
39 | import com.hjx.parent.databinding.ActivityErrorListBinding; | 39 | import com.hjx.parent.databinding.ActivityErrorListBinding; |
40 | import com.hjx.parent.dialog.ErrorEditDialog; | 40 | import com.hjx.parent.dialog.ErrorEditDialog; |
41 | import com.hjx.parent.dialog.TipDialog; | 41 | import com.hjx.parent.dialog.TipDialog; |
42 | import com.prws.common.bean.GradeAndSubject; | 42 | import com.prws.common.bean.GradeAndSubject; |
43 | import com.prws.common.bean.PageInfo; | 43 | import com.prws.common.bean.PageInfo; |
44 | import com.prws.common.bean.ResponseResult; | 44 | import com.prws.common.bean.ResponseResult; |
45 | import com.prws.common.bean.Subject; | 45 | import com.prws.common.bean.Subject; |
46 | import com.prws.common.bean.TopicBean; | 46 | import com.prws.common.bean.TopicBean; |
47 | import com.prws.common.net.NetWorks; | 47 | import com.prws.common.net.NetWorks; |
48 | import com.prws.common.utils.BitmapUtils; | 48 | import com.prws.common.utils.BitmapUtils; |
49 | import com.prws.common.utils.CommonUtil; | 49 | import com.prws.common.utils.CommonUtil; |
50 | import com.prws.common.utils.SharedPreferencesUtil; | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
51 | import com.prws.common.utils.dialog.MyButtomDialog; | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | import com.zhangteng.imagepicker.bean.ImageInfo; | 52 | import com.zhangteng.imagepicker.bean.ImageInfo; |
53 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 53 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
54 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 54 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
55 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 55 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
56 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 56 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
57 | import com.zhangteng.utils.IHandlerCallBack; | 57 | import com.zhangteng.utils.IHandlerCallBack; |
58 | 58 | ||
59 | import java.io.File; | 59 | import java.io.File; |
60 | import java.util.ArrayList; | 60 | import java.util.ArrayList; |
61 | import java.util.HashMap; | 61 | import java.util.HashMap; |
62 | import java.util.List; | 62 | import java.util.List; |
63 | import java.util.Map; | 63 | import java.util.Map; |
64 | 64 | ||
65 | import io.reactivex.Observer; | 65 | import io.reactivex.Observer; |
66 | import io.reactivex.disposables.Disposable; | 66 | import io.reactivex.disposables.Disposable; |
67 | 67 | ||
68 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { | 68 | public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> implements View.OnClickListener { |
69 | private TextView last; | 69 | private TextView last; |
70 | private String subject; | 70 | private String subject; |
71 | private String grade; | 71 | private String grade; |
72 | private String grade1; | 72 | private String grade1; |
73 | private String manger; | 73 | private String manger; |
74 | private String type = "全部"; | 74 | private String type = "全部"; |
75 | private String time = "全部"; | 75 | private String time = "全部"; |
76 | private FilterAdapter filterAdapter; | 76 | private FilterAdapter filterAdapter; |
77 | 77 | ||
78 | private GradeAdapter gradeAdapter; | 78 | private GradeAdapter gradeAdapter; |
79 | StudentBean studentBean; | 79 | StudentBean studentBean; |
80 | private int page = 1; | 80 | private int page = 1; |
81 | private ErrorAdapter adapter; | 81 | private ErrorAdapter adapter; |
82 | private int total; | 82 | private int total; |
83 | private int REQUEST_CODE_IMAGE = 123; | 83 | private int REQUEST_CODE_IMAGE = 123; |
84 | private String filePath; | 84 | private String filePath; |
85 | 85 | ||
86 | @Override | 86 | @Override |
87 | public void initView(Bundle savedInstanceState) { | 87 | public void initView(Bundle savedInstanceState) { |
88 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 88 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
89 | try { | 89 | try { |
90 | studentBean = new Gson().fromJson(student, StudentBean.class); | 90 | studentBean = new Gson().fromJson(student, StudentBean.class); |
91 | } catch (Exception e) { | 91 | } catch (Exception e) { |
92 | 92 | ||
93 | } | 93 | } |
94 | binding.ivBack.setOnClickListener(this); | 94 | binding.ivBack.setOnClickListener(this); |
95 | binding.tvFilterGrade.setOnClickListener(this); | 95 | binding.tvFilterGrade.setOnClickListener(this); |
96 | binding.tvFilterSubject.setOnClickListener(this); | 96 | binding.tvFilterSubject.setOnClickListener(this); |
97 | binding.tvFilterMore.setOnClickListener(this); | 97 | binding.tvFilterMore.setOnClickListener(this); |
98 | binding.tvFilterManage.setOnClickListener(this); | 98 | binding.tvFilterManage.setOnClickListener(this); |
99 | binding.tvEdit.setOnClickListener(this); | 99 | binding.tvEdit.setOnClickListener(this); |
100 | binding.tvAdd.setOnClickListener(this); | 100 | binding.tvAdd.setOnClickListener(this); |
101 | binding.llDelete.setOnClickListener(this); | 101 | binding.llDelete.setOnClickListener(this); |
102 | binding.tvSave.setOnClickListener(this); | 102 | binding.tvSave.setOnClickListener(this); |
103 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | 103 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); |
104 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | 104 | binding.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
105 | @Override | 105 | @Override |
106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | 106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
107 | if (binding.llEmpty.getVisibility() != View.VISIBLE) { | 107 | if (binding.llEmpty.getVisibility() != View.VISIBLE) { |
108 | adapter.checkAll(isChecked); | 108 | adapter.checkAll(isChecked); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | }); | 111 | }); |
112 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); | 112 | RadioButton timeButton = (RadioButton) binding.groupTime.getChildAt(3); |
113 | timeButton.setChecked(true); | 113 | timeButton.setChecked(true); |
114 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 114 | binding.groupTime.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
115 | @Override | 115 | @Override |
116 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 116 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
117 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 117 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
118 | time = rcheck.getText().toString(); | 118 | time = rcheck.getText().toString(); |
119 | refreshError(); | 119 | refreshError(); |
120 | } | 120 | } |
121 | }); | 121 | }); |
122 | 122 | ||
123 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); | 123 | RadioButton typeButton = (RadioButton) binding.groupType.getChildAt(2); |
124 | typeButton.setChecked(true); | 124 | typeButton.setChecked(true); |
125 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 125 | binding.groupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
126 | @Override | 126 | @Override |
127 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 127 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
128 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 128 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
129 | type = rcheck.getText().toString(); | 129 | type = rcheck.getText().toString(); |
130 | refreshError(); | 130 | refreshError(); |
131 | } | 131 | } |
132 | }); | 132 | }); |
133 | refreshError(); | 133 | refreshError(); |
134 | binding.ivChange.setOnClickListener(new View.OnClickListener() { | 134 | binding.ivChange.setOnClickListener(new View.OnClickListener() { |
135 | @Override | 135 | @Override |
136 | public void onClick(View v) { | 136 | public void onClick(View v) { |
137 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { | 137 | if (SharedPreferencesUtil.getData("role", "").equals("parent")) { |
138 | Intent intent = new Intent(context, ChooseActivity.class); | 138 | Intent intent = new Intent(context, ChooseActivity.class); |
139 | intent.putExtra("needBack", true); | 139 | intent.putExtra("needBack", true); |
140 | startActivity(intent); | 140 | startActivity(intent); |
141 | } else { | 141 | } else { |
142 | Intent intent = new Intent(context, TeacherChooseActivity.class); | 142 | Intent intent = new Intent(context, TeacherChooseActivity.class); |
143 | intent.putExtra("needBack", true); | 143 | intent.putExtra("needBack", true); |
144 | startActivity(intent); | 144 | startActivity(intent); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | }); | 147 | }); |
148 | setGradeFilter(); | 148 | setGradeFilter(); |
149 | } | 149 | } |
150 | 150 | ||
151 | private void setGradeFilter() { | 151 | private void setGradeFilter() { |
152 | if (TextUtils.isEmpty(grade)) { | 152 | if (TextUtils.isEmpty(grade)) { |
153 | grade = "全部"; | 153 | grade = "全部"; |
154 | } | 154 | } |
155 | List<String> grades = new ArrayList<>(); | 155 | List<String> grades = new ArrayList<>(); |
156 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 156 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
157 | grades.add(gradeAndSubject.getGrade().getGrade()); | 157 | grades.add(gradeAndSubject.getGrade().getGrade()); |
158 | } | 158 | } |
159 | grades.add("全部"); | 159 | grades.add("全部"); |
160 | gradeAdapter = new GradeAdapter(context, new GradeAdapter.Filter() { | 160 | gradeAdapter = new GradeAdapter(context, new GradeAdapter.Filter() { |
161 | @Override | 161 | @Override |
162 | public void onSelect(String select) { | 162 | public void onSelect(String select) { |
163 | grade = select; | 163 | grade = select; |
164 | page = 1; | 164 | page = 1; |
165 | gradeAdapter.refresh(select); | 165 | gradeAdapter.refresh(select); |
166 | refreshError(); | 166 | refreshError(); |
167 | } | 167 | } |
168 | }, grades, grade); | 168 | }, grades, grade); |
169 | binding.recycleGrade.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 169 | binding.recycleGrade.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
170 | binding.recycleGrade.setAdapter(gradeAdapter); | 170 | binding.recycleGrade.setAdapter(gradeAdapter); |
171 | binding.groupGrade.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | 171 | binding.groupGrade.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
172 | @Override | 172 | @Override |
173 | public void onCheckedChanged(RadioGroup group, int checkedId) { | 173 | public void onCheckedChanged(RadioGroup group, int checkedId) { |
174 | RadioButton rcheck = (RadioButton) findViewById(checkedId); | 174 | RadioButton rcheck = (RadioButton) findViewById(checkedId); |
175 | grade1 = rcheck.getText().toString(); | 175 | grade1 = rcheck.getText().toString(); |
176 | page = 1; | 176 | page = 1; |
177 | refreshError(); | 177 | refreshError(); |
178 | } | 178 | } |
179 | }); | 179 | }); |
180 | } | 180 | } |
181 | 181 | ||
182 | @Override | 182 | @Override |
183 | protected ActivityErrorListBinding getViewBinding() { | 183 | protected ActivityErrorListBinding getViewBinding() { |
184 | return ActivityErrorListBinding.inflate(getLayoutInflater()); | 184 | return ActivityErrorListBinding.inflate(getLayoutInflater()); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | @Override | 188 | @Override |
189 | public void onClick(View v) { | 189 | public void onClick(View v) { |
190 | switch (v.getId()) { | 190 | switch (v.getId()) { |
191 | case R.id.iv_back: | 191 | case R.id.iv_back: |
192 | finish(); | 192 | finish(); |
193 | break; | 193 | break; |
194 | case R.id.tv_filter_grade: | 194 | case R.id.tv_filter_grade: |
195 | showFilerGrade(); | 195 | showFilerGrade(); |
196 | break; | 196 | break; |
197 | case R.id.tv_filter_subject: | 197 | case R.id.tv_filter_subject: |
198 | List<String> subjects = new ArrayList<>(); | 198 | List<String> subjects = new ArrayList<>(); |
199 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { | 199 | for (GradeAndSubject gradeAndSubject : App.getInstance().getGradeAndSubjects()) { |
200 | for (Subject subject : gradeAndSubject.getSubjects()) { | 200 | for (Subject subject : gradeAndSubject.getSubjects()) { |
201 | if (!subjects.contains(subject.getSubject())) { | 201 | if (!subjects.contains(subject.getSubject())) { |
202 | subjects.add(subject.getSubject()); | 202 | subjects.add(subject.getSubject()); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | } | 205 | } |
206 | subjects.add("全部"); | 206 | subjects.add("全部"); |
207 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); | 207 | setFilterAdapter(subjects, binding.tvFilterSubject, subject); |
208 | break; | 208 | break; |
209 | case R.id.tv_filter_manage: | 209 | case R.id.tv_filter_manage: |
210 | List<String> manages = new ArrayList<>(); | 210 | List<String> manages = new ArrayList<>(); |
211 | manages.add("已掌握"); | 211 | manages.add("已掌握"); |
212 | manages.add("未掌握"); | 212 | manages.add("未掌握"); |
213 | manages.add("全部"); | 213 | manages.add("全部"); |
214 | setFilterAdapter(manages, binding.tvFilterManage, manger); | 214 | setFilterAdapter(manages, binding.tvFilterManage, manger); |
215 | break; | 215 | break; |
216 | case R.id.tv_filter_more: | 216 | case R.id.tv_filter_more: |
217 | showFilterMore(); | 217 | showFilterMore(); |
218 | break; | 218 | break; |
219 | case R.id.tv_edit: | 219 | case R.id.tv_edit: |
220 | if (adapter == null) break; | ||
220 | if (adapter.edit) { | 221 | if (adapter.edit) { |
221 | adapter.setEdit(false); | 222 | adapter.setEdit(false); |
222 | binding.tvSave.setVisibility(View.GONE); | 223 | binding.tvSave.setVisibility(View.GONE); |
223 | binding.tvAdd.setVisibility(View.VISIBLE); | 224 | binding.tvAdd.setVisibility(View.VISIBLE); |
224 | binding.checkbox.setVisibility(View.GONE); | 225 | binding.checkbox.setVisibility(View.GONE); |
225 | binding.llDelete.setVisibility(View.GONE); | 226 | binding.llDelete.setVisibility(View.GONE); |
226 | binding.ivBack.setVisibility(View.VISIBLE); | 227 | binding.ivBack.setVisibility(View.VISIBLE); |
227 | binding.tvEdit.setText("编辑"); | 228 | binding.tvEdit.setText("编辑"); |
228 | } else { | 229 | } else { |
229 | adapter.setEdit(true); | 230 | adapter.setEdit(true); |
230 | binding.tvSave.setVisibility(View.VISIBLE); | 231 | binding.tvSave.setVisibility(View.VISIBLE); |
231 | binding.tvAdd.setVisibility(View.GONE); | 232 | binding.tvAdd.setVisibility(View.GONE); |
232 | binding.llDelete.setVisibility(View.VISIBLE); | 233 | binding.llDelete.setVisibility(View.VISIBLE); |
233 | binding.checkbox.setVisibility(View.VISIBLE); | 234 | binding.checkbox.setVisibility(View.VISIBLE); |
234 | binding.ivBack.setVisibility(View.GONE); | 235 | binding.ivBack.setVisibility(View.GONE); |
235 | binding.tvEdit.setText("取消"); | 236 | binding.tvEdit.setText("取消"); |
236 | } | 237 | } |
237 | adapter.notifyDataSetChanged(); | 238 | adapter.notifyDataSetChanged(); |
238 | break; | 239 | break; |
239 | case R.id.ll_delete: | 240 | case R.id.ll_delete: |
240 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { | 241 | showTipDialog("温馨提示", "确认删除已勾选的错题?", "取消", "确认", new TipDialog.TipDialogInterface() { |
241 | @Override | 242 | @Override |
242 | public void onConfirm(Dialog dialog) { | 243 | public void onConfirm(Dialog dialog) { |
243 | deleteError(adapter.getChecKList()); | 244 | deleteError(adapter.getChecKList()); |
244 | dialog.dismiss(); | 245 | dialog.dismiss(); |
245 | } | 246 | } |
246 | 247 | ||
247 | @Override | 248 | @Override |
248 | public void onCancel(Dialog dialog) { | 249 | public void onCancel(Dialog dialog) { |
249 | dialog.dismiss(); | 250 | dialog.dismiss(); |
250 | } | 251 | } |
251 | }); | 252 | }); |
252 | break; | 253 | break; |
253 | case R.id.tv_add: | 254 | case R.id.tv_add: |
254 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { | 255 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE)) { |
255 | XXPermissions.with(context) | 256 | XXPermissions.with(context) |
256 | // 申请多个权限 | 257 | // 申请多个权限 |
257 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) | 258 | .permission(Permission.CAMERA, Permission.MANAGE_EXTERNAL_STORAGE) |
258 | .request(new OnPermissionCallback() { | 259 | .request(new OnPermissionCallback() { |
259 | @Override | 260 | @Override |
260 | public void onGranted(List<String> permissions, boolean all) { | 261 | public void onGranted(List<String> permissions, boolean all) { |
261 | if (all) { | 262 | if (all) { |
262 | //开启扫码界面 | 263 | //开启扫码界面 |
263 | showButtonDialog(); | 264 | showButtonDialog(); |
264 | } else { | 265 | } else { |
265 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 266 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
269 | @Override | 270 | @Override |
270 | public void onDenied(List<String> permissions, boolean never) { | 271 | public void onDenied(List<String> permissions, boolean never) { |
271 | XXPermissions.startPermissionActivity(context, permissions); | 272 | XXPermissions.startPermissionActivity(context, permissions); |
272 | } | 273 | } |
273 | }); | 274 | }); |
274 | } else { | 275 | } else { |
275 | showButtonDialog(); | 276 | showButtonDialog(); |
276 | } | 277 | } |
277 | break; | 278 | break; |
278 | case R.id.tv_save: | 279 | case R.id.tv_save: |
279 | if (adapter.getChecKList().size() > 0) { | 280 | if (adapter.getChecKList().size() > 0) { |
280 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { | 281 | ErrorEditDialog errorEditDialog = new ErrorEditDialog(context, adapter.getChecKList(), new ErrorEditDialog.EditInterface() { |
281 | @Override | 282 | @Override |
282 | public void edit(String name, String grade, String subject, int type, int reason, int manager) { | 283 | public void edit(String name, String grade, String subject, int type, int reason, int manager) { |
283 | adapter.setEdit(false); | 284 | adapter.setEdit(false); |
284 | binding.tvSave.setVisibility(View.GONE); | 285 | binding.tvSave.setVisibility(View.GONE); |
285 | binding.tvAdd.setVisibility(View.VISIBLE); | 286 | binding.tvAdd.setVisibility(View.VISIBLE); |
286 | binding.checkbox.setVisibility(View.GONE); | 287 | binding.checkbox.setVisibility(View.GONE); |
287 | binding.llDelete.setVisibility(View.GONE); | 288 | binding.llDelete.setVisibility(View.GONE); |
288 | binding.ivBack.setVisibility(View.VISIBLE); | 289 | binding.ivBack.setVisibility(View.VISIBLE); |
289 | binding.tvEdit.setText("编辑"); | 290 | binding.tvEdit.setText("编辑"); |
290 | page = 1; | 291 | page = 1; |
291 | refreshError(); | 292 | refreshError(); |
292 | } | 293 | } |
293 | 294 | ||
294 | }); | 295 | }); |
295 | errorEditDialog.show(); | 296 | errorEditDialog.show(); |
296 | } | 297 | } |
297 | break; | 298 | break; |
298 | } | 299 | } |
299 | } | 300 | } |
300 | 301 | ||
301 | private void showButtonDialog() { | 302 | private void showButtonDialog() { |
302 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 303 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
303 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 304 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
304 | dialog.setContentView(bottomView); | 305 | dialog.setContentView(bottomView); |
305 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 306 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
306 | @Override | 307 | @Override |
307 | public void onClick(View view) { | 308 | public void onClick(View view) { |
308 | dialog.dismiss(); | 309 | dialog.dismiss(); |
309 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 310 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
310 | //确保有相机来处理Intent | 311 | //确保有相机来处理Intent |
311 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 312 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
312 | File photoFile = new File(filePath); | 313 | File photoFile = new File(filePath); |
313 | if (photoFile != null) { | 314 | if (photoFile != null) { |
314 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 315 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
315 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 316 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
316 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 317 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
317 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 318 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
318 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 319 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
319 | } | 320 | } |
320 | } | 321 | } |
321 | }); | 322 | }); |
322 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 323 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
323 | @Override | 324 | @Override |
324 | public void onClick(View view) { | 325 | public void onClick(View view) { |
325 | dialog.dismiss(); | 326 | dialog.dismiss(); |
326 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 327 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
327 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 328 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
328 | .multiSelect(true) //是否多选 | 329 | .multiSelect(true) //是否多选 |
329 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 330 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
330 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 331 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
331 | .maxImageSelectable(5) //图片可选择数 | 332 | .maxImageSelectable(5) //图片可选择数 |
332 | .maxHeight(1920) //图片最大高度 | 333 | .maxHeight(1920) //图片最大高度 |
333 | .maxWidth(1920) //图片最大宽度 | 334 | .maxWidth(1920) //图片最大宽度 |
334 | .maxImageSize(3) //图片最大大小Mb | 335 | .maxImageSize(3) //图片最大大小Mb |
335 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 336 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); |
336 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | 337 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); |
337 | 338 | ||
338 | } | 339 | } |
339 | }); | 340 | }); |
340 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 341 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
341 | @Override | 342 | @Override |
342 | public void onClick(View view) { | 343 | public void onClick(View view) { |
343 | dialog.dismiss(); | 344 | dialog.dismiss(); |
344 | } | 345 | } |
345 | }); | 346 | }); |
346 | dialog.show(); | 347 | dialog.show(); |
347 | } | 348 | } |
348 | 349 | ||
349 | private void deleteError(List<TopicBean> topicBeans) { | 350 | private void deleteError(List<TopicBean> topicBeans) { |
350 | List<String> list = new ArrayList<>(); | 351 | List<String> list = new ArrayList<>(); |
351 | for (int i = 0; i < topicBeans.size(); i++) { | 352 | for (int i = 0; i < topicBeans.size(); i++) { |
352 | list.add(topicBeans.get(i).getId()); | 353 | list.add(topicBeans.get(i).getId()); |
353 | } | 354 | } |
354 | NetWorks.deleteError(list, new Observer<ResponseResult>() { | 355 | NetWorks.deleteError(list, new Observer<ResponseResult>() { |
355 | @Override | 356 | @Override |
356 | public void onSubscribe(Disposable d) { | 357 | public void onSubscribe(Disposable d) { |
357 | 358 | ||
358 | } | 359 | } |
359 | 360 | ||
360 | @Override | 361 | @Override |
361 | public void onNext(ResponseResult responseResult) { | 362 | public void onNext(ResponseResult responseResult) { |
362 | if (responseResult.getCode() == 200) { | 363 | if (responseResult.getCode() == 200) { |
363 | adapter.setEdit(false); | 364 | adapter.setEdit(false); |
364 | binding.tvSave.setVisibility(View.GONE); | 365 | binding.tvSave.setVisibility(View.GONE); |
365 | binding.tvAdd.setVisibility(View.VISIBLE); | 366 | binding.tvAdd.setVisibility(View.VISIBLE); |
366 | binding.checkbox.setVisibility(View.GONE); | 367 | binding.checkbox.setVisibility(View.GONE); |
367 | binding.llDelete.setVisibility(View.GONE); | 368 | binding.llDelete.setVisibility(View.GONE); |
368 | binding.ivBack.setVisibility(View.VISIBLE); | 369 | binding.ivBack.setVisibility(View.VISIBLE); |
369 | binding.tvEdit.setText("编辑"); | 370 | binding.tvEdit.setText("编辑"); |
370 | page = 1; | 371 | page = 1; |
371 | refreshError(); | 372 | refreshError(); |
372 | } | 373 | } |
373 | } | 374 | } |
374 | 375 | ||
375 | @Override | 376 | @Override |
376 | public void onError(Throwable e) { | 377 | public void onError(Throwable e) { |
377 | 378 | ||
378 | } | 379 | } |
379 | 380 | ||
380 | @Override | 381 | @Override |
381 | public void onComplete() { | 382 | public void onComplete() { |
382 | 383 | ||
383 | } | 384 | } |
384 | }); | 385 | }); |
385 | } | 386 | } |
386 | 387 | ||
387 | private void showFilerGrade() { | 388 | private void showFilerGrade() { |
388 | binding.recycleFilter.setVisibility(View.GONE); | 389 | binding.recycleFilter.setVisibility(View.GONE); |
389 | binding.llFilterMore.setVisibility(View.GONE); | 390 | binding.llFilterMore.setVisibility(View.GONE); |
390 | if (binding.llFilterGrade.getVisibility() == View.VISIBLE) { | 391 | if (binding.llFilterGrade.getVisibility() == View.VISIBLE) { |
391 | binding.llFilterGrade.setVisibility(View.GONE); | 392 | binding.llFilterGrade.setVisibility(View.GONE); |
392 | binding.tvFilterGrade.setTextColor(getColor(R.color.text_title)); | 393 | binding.tvFilterGrade.setTextColor(getColor(R.color.text_title)); |
393 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 394 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
394 | // 这一步必须要做,否则不会显示. | 395 | // 这一步必须要做,否则不会显示. |
395 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 396 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
396 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable, null); | 397 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable, null); |
397 | } else { | 398 | } else { |
398 | binding.llFilterGrade.setVisibility(View.VISIBLE); | 399 | binding.llFilterGrade.setVisibility(View.VISIBLE); |
399 | if (last != null) { | 400 | if (last != null) { |
400 | last.setTextColor(getColor(R.color.text_title)); | 401 | last.setTextColor(getColor(R.color.text_title)); |
401 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 402 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
402 | // 这一步必须要做,否则不会显示. | 403 | // 这一步必须要做,否则不会显示. |
403 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 404 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
404 | last.setCompoundDrawables(null, null, drawable, null); | 405 | last.setCompoundDrawables(null, null, drawable, null); |
405 | } | 406 | } |
406 | binding.tvFilterGrade.setTextColor(Color.parseColor("#1C90F3")); | 407 | binding.tvFilterGrade.setTextColor(Color.parseColor("#1C90F3")); |
407 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 408 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
408 | // 这一步必须要做,否则不会显示. | 409 | // 这一步必须要做,否则不会显示. |
409 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 410 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
410 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable1, null); | 411 | binding.tvFilterGrade.setCompoundDrawables(null, null, drawable1, null); |
411 | last = binding.tvFilterGrade; | 412 | last = binding.tvFilterGrade; |
412 | } | 413 | } |
413 | 414 | ||
414 | } | 415 | } |
415 | 416 | ||
416 | private void showFilterMore() { | 417 | private void showFilterMore() { |
417 | binding.recycleFilter.setVisibility(View.GONE); | 418 | binding.recycleFilter.setVisibility(View.GONE); |
418 | binding.llFilterGrade.setVisibility(View.GONE); | 419 | binding.llFilterGrade.setVisibility(View.GONE); |
419 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { | 420 | if (binding.llFilterMore.getVisibility() == View.VISIBLE) { |
420 | binding.llFilterMore.setVisibility(View.GONE); | 421 | binding.llFilterMore.setVisibility(View.GONE); |
421 | binding.tvFilterMore.setTextColor(getColor(R.color.text_title)); | 422 | binding.tvFilterMore.setTextColor(getColor(R.color.text_title)); |
422 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 423 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
423 | // 这一步必须要做,否则不会显示. | 424 | // 这一步必须要做,否则不会显示. |
424 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 425 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
425 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable, null); | 426 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable, null); |
426 | } else { | 427 | } else { |
427 | binding.llFilterMore.setVisibility(View.VISIBLE); | 428 | binding.llFilterMore.setVisibility(View.VISIBLE); |
428 | if (last != null) { | 429 | if (last != null) { |
429 | last.setTextColor(getColor(R.color.text_title)); | 430 | last.setTextColor(getColor(R.color.text_title)); |
430 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 431 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
431 | // 这一步必须要做,否则不会显示. | 432 | // 这一步必须要做,否则不会显示. |
432 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 433 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
433 | last.setCompoundDrawables(null, null, drawable, null); | 434 | last.setCompoundDrawables(null, null, drawable, null); |
434 | } | 435 | } |
435 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); | 436 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); |
436 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 437 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
437 | // 这一步必须要做,否则不会显示. | 438 | // 这一步必须要做,否则不会显示. |
438 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | 439 | drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); |
439 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); | 440 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); |
440 | last = binding.tvFilterMore; | 441 | last = binding.tvFilterMore; |
441 | } | 442 | } |
442 | } | 443 | } |
443 | 444 | ||
444 | private void setFilterAdapter(List<String> list, TextView textView, String select) { | 445 | private void setFilterAdapter(List<String> list, TextView textView, String select) { |
445 | if (TextUtils.isEmpty(select)) { | 446 | if (TextUtils.isEmpty(select)) { |
446 | select = "全部"; | 447 | select = "全部"; |
447 | } | 448 | } |
448 | binding.llFilterGrade.setVisibility(View.GONE); | 449 | binding.llFilterGrade.setVisibility(View.GONE); |
449 | binding.llFilterMore.setVisibility(View.GONE); | 450 | binding.llFilterMore.setVisibility(View.GONE); |
450 | if (last != null && (last.getId() == R.id.tv_filter_more || last.getId() == R.id.tv_filter_grade)) { | 451 | if (last != null && (last.getId() == R.id.tv_filter_more || last.getId() == R.id.tv_filter_grade)) { |
451 | last.setTextColor(getColor(R.color.text_title)); | 452 | last.setTextColor(getColor(R.color.text_title)); |
452 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 453 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
453 | // 这一步必须要做,否则不会显示. | 454 | // 这一步必须要做,否则不会显示. |
454 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 455 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
455 | last.setCompoundDrawables(null, null, drawable, null); | 456 | last.setCompoundDrawables(null, null, drawable, null); |
456 | } | 457 | } |
457 | if (binding.recycleFilter.getVisibility() == View.GONE) { | 458 | if (binding.recycleFilter.getVisibility() == View.GONE) { |
458 | if (filterAdapter != null) { | 459 | if (filterAdapter != null) { |
459 | filterAdapter.refresh(list, textView, select); | 460 | filterAdapter.refresh(list, textView, select); |
460 | } else { | 461 | } else { |
461 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { | 462 | filterAdapter = new FilterAdapter(context, new FilterAdapter.Filter() { |
462 | @Override | 463 | @Override |
463 | public void onSelect(TextView type, String select) { | 464 | public void onSelect(TextView type, String select) { |
464 | switch (type.getId()) { | 465 | switch (type.getId()) { |
465 | case R.id.tv_filter_subject: | 466 | case R.id.tv_filter_subject: |
466 | subject = select; | 467 | subject = select; |
467 | break; | 468 | break; |
468 | case R.id.tv_filter_manage: | 469 | case R.id.tv_filter_manage: |
469 | manger = select; | 470 | manger = select; |
470 | break; | 471 | break; |
471 | } | 472 | } |
472 | page = 1; | 473 | page = 1; |
473 | filterAdapter.refresh(select); | 474 | filterAdapter.refresh(select); |
474 | refreshError(); | 475 | refreshError(); |
475 | } | 476 | } |
476 | }, list, textView, select); | 477 | }, list, textView, select); |
477 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); | 478 | binding.recycleFilter.setLayoutManager(new GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)); |
478 | binding.recycleFilter.setAdapter(filterAdapter); | 479 | binding.recycleFilter.setAdapter(filterAdapter); |
479 | } | 480 | } |
480 | binding.recycleFilter.setVisibility(View.VISIBLE); | 481 | binding.recycleFilter.setVisibility(View.VISIBLE); |
481 | textView.setTextColor(Color.parseColor("#1C90F3")); | 482 | textView.setTextColor(Color.parseColor("#1C90F3")); |
482 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); | 483 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_blue); |
483 | // 这一步必须要做,否则不会显示. | 484 | // 这一步必须要做,否则不会显示. |
484 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 485 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
485 | textView.setCompoundDrawables(null, null, drawable, null); | 486 | textView.setCompoundDrawables(null, null, drawable, null); |
486 | last = textView; | 487 | last = textView; |
487 | } else { | 488 | } else { |
488 | if (textView.getId() == last.getId()) { | 489 | if (textView.getId() == last.getId()) { |
489 | binding.recycleFilter.setVisibility(View.GONE); | 490 | binding.recycleFilter.setVisibility(View.GONE); |
490 | textView.setTextColor(getColor(R.color.text_title)); | 491 | textView.setTextColor(getColor(R.color.text_title)); |
491 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 492 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
492 | // 这一步必须要做,否则不会显示. | 493 | // 这一步必须要做,否则不会显示. |
493 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 494 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
494 | textView.setCompoundDrawables(null, null, drawable, null); | 495 | textView.setCompoundDrawables(null, null, drawable, null); |
495 | } else { | 496 | } else { |
496 | filterAdapter.refresh(list, textView, select); | 497 | filterAdapter.refresh(list, textView, select); |
497 | last.setTextColor(getColor(R.color.text_title)); | 498 | last.setTextColor(getColor(R.color.text_title)); |
498 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | 499 | Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); |
499 | // 这一步必须要做,否则不会显示. | 500 | // 这一步必须要做,否则不会显示. |
500 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 501 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
501 | last.setCompoundDrawables(null, null, drawable, null); | 502 | last.setCompoundDrawables(null, null, drawable, null); |
502 | textView.setTextColor(Color.parseColor("#1C90F3")); | 503 | textView.setTextColor(Color.parseColor("#1C90F3")); |
503 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); | 504 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
504 | // 这一步必须要做,否则不会显示. | 505 | // 这一步必须要做,否则不会显示. |
505 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | 506 | drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); |
506 | textView.setCompoundDrawables(null, null, drawable1, null); | 507 | textView.setCompoundDrawables(null, null, drawable1, null); |
507 | last = textView; | 508 | last = textView; |
508 | } | 509 | } |
509 | } | 510 | } |
510 | } | 511 | } |
511 | 512 | ||
512 | private void refreshError() { | 513 | private void refreshError() { |
513 | Map map = new HashMap(); | 514 | Map map = new HashMap(); |
514 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { | 515 | if (!TextUtils.isEmpty(subject) && !"全部".equals(subject)) { |
515 | map.put("subject", subject); | 516 | map.put("subject", subject); |
516 | } | 517 | } |
517 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { | 518 | if (!TextUtils.isEmpty(grade) && !"全部".equals(grade)) { |
518 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { | 519 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { |
519 | map.put("grade", grade + grade1); | 520 | map.put("grade", grade + grade1); |
520 | } else { | 521 | } else { |
521 | map.put("grade", grade); | 522 | map.put("grade", grade); |
522 | } | 523 | } |
523 | } else { | 524 | } else { |
524 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { | 525 | if (!TextUtils.isEmpty(grade1) && !"全部".equals(grade1)) { |
525 | map.put("grade", grade1); | 526 | map.put("grade", grade1); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { | 529 | if (!TextUtils.isEmpty(time) && !"全部".equals(time)) { |
529 | if ("一周内".equals(time)) { | 530 | if ("一周内".equals(time)) { |
530 | map.put("time", 6); | 531 | map.put("time", 6); |
531 | } else if ("一个月内".equals(time)) { | 532 | } else if ("一个月内".equals(time)) { |
532 | map.put("time", 30); | 533 | map.put("time", 30); |
533 | } else if ("三个月内".equals(time)) { | 534 | } else if ("三个月内".equals(time)) { |
534 | map.put("time", 90); | 535 | map.put("time", 90); |
535 | } | 536 | } |
536 | } | 537 | } |
537 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { | 538 | if (!TextUtils.isEmpty(type) && !"全部".equals(type)) { |
538 | map.put("type", "课内".equals(type) ? 0 : 1); | 539 | map.put("type", "课内".equals(type) ? 0 : 1); |
539 | } | 540 | } |
540 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { | 541 | if (!TextUtils.isEmpty(manger) && !"全部".equals(manger)) { |
541 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); | 542 | map.put("controlFlag", "已掌握".equals(manger) ? 0 : 1); |
542 | } | 543 | } |
543 | map.put("stuId", studentBean.getStuId()); | 544 | map.put("stuId", studentBean.getStuId()); |
544 | map.put("pageSize", 10); | 545 | map.put("pageSize", 10); |
545 | map.put("pageNum", page); | 546 | map.put("pageNum", page); |
546 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 547 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
547 | @Override | 548 | @Override |
548 | public void onSubscribe(Disposable d) { | 549 | public void onSubscribe(Disposable d) { |
549 | 550 | ||
550 | } | 551 | } |
551 | 552 | ||
552 | @Override | 553 | @Override |
553 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 554 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
554 | if (result.getData() != null && result.getCode() == 200) { | 555 | if (result.getData() != null && result.getCode() == 200) { |
555 | total = result.getData().getTotal(); | 556 | total = result.getData().getTotal(); |
556 | List<TopicBean> topicBeans = result.getData().getList(); | 557 | List<TopicBean> topicBeans = result.getData().getList(); |
557 | loadError(topicBeans); | 558 | loadError(topicBeans); |
558 | } | 559 | } |
559 | } | 560 | } |
560 | 561 | ||
561 | @Override | 562 | @Override |
562 | public void onError(Throwable e) { | 563 | public void onError(Throwable e) { |
563 | e.toString(); | 564 | e.toString(); |
564 | } | 565 | } |
565 | 566 | ||
566 | @Override | 567 | @Override |
567 | public void onComplete() { | 568 | public void onComplete() { |
568 | 569 | ||
569 | } | 570 | } |
570 | }); | 571 | }); |
571 | } | 572 | } |
572 | 573 | ||
573 | private void loadError(List<TopicBean> list) { | 574 | private void loadError(List<TopicBean> list) { |
574 | if (list.size() > 0) { | 575 | if (list.size() > 0) { |
575 | binding.recycle.setVisibility(View.VISIBLE); | 576 | binding.recycle.setVisibility(View.VISIBLE); |
576 | binding.llEmpty.setVisibility(View.GONE); | 577 | binding.llEmpty.setVisibility(View.GONE); |
577 | if (adapter != null) { | 578 | if (adapter != null) { |
578 | if (page > 1) { | 579 | if (page > 1) { |
579 | adapter.addData(list); | 580 | adapter.addData(list); |
580 | } else { | 581 | } else { |
581 | adapter.refresh(list); | 582 | adapter.refresh(list); |
582 | } | 583 | } |
583 | } else { | 584 | } else { |
584 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { | 585 | adapter = new ErrorAdapter(context, list, false, new ErrorAdapter.CheckInterface() { |
585 | @Override | 586 | @Override |
586 | public void onErrorCheck() { | 587 | public void onErrorCheck() { |
587 | if (adapter.getChecKList().size() > 0) { | 588 | if (adapter.getChecKList().size() > 0) { |
588 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); | 589 | binding.tvSave.setText("批量修改标签" + "(" + adapter.getChecKList().size() + ")"); |
589 | } else { | 590 | } else { |
590 | binding.tvSave.setText("批量修改标签"); | 591 | binding.tvSave.setText("批量修改标签"); |
591 | } | 592 | } |
592 | } | 593 | } |
593 | }); | 594 | }); |
594 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); | 595 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); |
595 | binding.recycle.setLayoutManager(linearLayoutManager); | 596 | binding.recycle.setLayoutManager(linearLayoutManager); |
596 | binding.recycle.setAdapter(adapter); | 597 | binding.recycle.setAdapter(adapter); |
597 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { | 598 | binding.recycle.addOnScrollListener(new LoadMoreOnScrollListener(linearLayoutManager) { |
598 | @Override | 599 | @Override |
599 | public void onLoadMore(int currentPage) { | 600 | public void onLoadMore(int currentPage) { |
600 | if (currentPage > page) { | 601 | if (currentPage > page) { |
601 | new Thread(new Runnable() { | 602 | new Thread(new Runnable() { |
602 | @Override | 603 | @Override |
603 | public void run() { | 604 | public void run() { |
604 | try { | 605 | try { |
605 | runOnUiThread(new Runnable() { | 606 | runOnUiThread(new Runnable() { |
606 | @Override | 607 | @Override |
607 | public void run() { | 608 | public void run() { |
608 | if (page * 10 < total) { | 609 | if (page * 10 < total) { |
609 | page++; | 610 | page++; |
610 | refreshError(); | 611 | refreshError(); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | }); | 614 | }); |
614 | } catch (Exception e) { | 615 | } catch (Exception e) { |
615 | e.printStackTrace(); | 616 | e.printStackTrace(); |
616 | } | 617 | } |
617 | } | 618 | } |
618 | }).start(); | 619 | }).start(); |
619 | } | 620 | } |
620 | } | 621 | } |
621 | }); | 622 | }); |
622 | } | 623 | } |
623 | } else { | 624 | } else { |
624 | if (page == 1) { | 625 | if (page == 1) { |
625 | binding.recycle.setVisibility(View.GONE); | 626 | binding.recycle.setVisibility(View.GONE); |
626 | binding.llEmpty.setVisibility(View.VISIBLE); | 627 | binding.llEmpty.setVisibility(View.VISIBLE); |
627 | } | 628 | } |
628 | } | 629 | } |
629 | } | 630 | } |
630 | 631 | ||
631 | @Override | 632 | @Override |
632 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 633 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
633 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 634 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
634 | if (adapter != null && adapter.edit) { | 635 | if (adapter != null && adapter.edit) { |
635 | adapter.setEdit(false); | 636 | adapter.setEdit(false); |
636 | binding.tvSave.setVisibility(View.GONE); | 637 | binding.tvSave.setVisibility(View.GONE); |
637 | binding.tvAdd.setVisibility(View.VISIBLE); | 638 | binding.tvAdd.setVisibility(View.VISIBLE); |
638 | binding.checkbox.setVisibility(View.GONE); | 639 | binding.checkbox.setVisibility(View.GONE); |
639 | binding.llDelete.setVisibility(View.GONE); | 640 | binding.llDelete.setVisibility(View.GONE); |
640 | binding.ivBack.setVisibility(View.VISIBLE); | 641 | binding.ivBack.setVisibility(View.VISIBLE); |
641 | binding.tvEdit.setText("编辑"); | 642 | binding.tvEdit.setText("编辑"); |
642 | adapter.notifyDataSetChanged(); | 643 | adapter.notifyDataSetChanged(); |
643 | } else { | 644 | } else { |
644 | finish(); | 645 | finish(); |
645 | } | 646 | } |
646 | return true; | 647 | return true; |
647 | } | 648 | } |
648 | return super.onKeyDown(keyCode, event); | 649 | return super.onKeyDown(keyCode, event); |
649 | } | 650 | } |
650 | 651 | ||
651 | @Override | 652 | @Override |
652 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 653 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
653 | super.onActivityResult(requestCode, resultCode, data); | 654 | super.onActivityResult(requestCode, resultCode, data); |
654 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 655 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
655 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 656 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
656 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 657 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
657 | CommonUtil.saveBitmapToUri(b, path); | 658 | CommonUtil.saveBitmapToUri(b, path); |
658 | List<String> strings = new ArrayList<>(); | 659 | List<String> strings = new ArrayList<>(); |
659 | Intent intent = new Intent(context, ImageActivity.class); | 660 | Intent intent = new Intent(context, ImageActivity.class); |
660 | strings.add(path); | 661 | strings.add(path); |
661 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 662 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
662 | startActivity(intent); | 663 | startActivity(intent); |
663 | } | 664 | } |
664 | } | 665 | } |
665 | 666 | ||
666 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 667 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
667 | private String TAG = "---ImagePicker---"; | 668 | private String TAG = "---ImagePicker---"; |
668 | List<ImageInfo> photoList = new ArrayList<>(); | 669 | List<ImageInfo> photoList = new ArrayList<>(); |
669 | 670 | ||
670 | @Override | 671 | @Override |
671 | public void onStart() { | 672 | public void onStart() { |
672 | Log.i(TAG, "onStart: 开启"); | 673 | Log.i(TAG, "onStart: 开启"); |
673 | } | 674 | } |
674 | 675 | ||
675 | @Override | 676 | @Override |
676 | public void onSuccess(List<ImageInfo> photoList) { | 677 | public void onSuccess(List<ImageInfo> photoList) { |
677 | this.photoList = photoList; | 678 | this.photoList = photoList; |
678 | Log.i(TAG, "onSuccess: 返回数据"); | 679 | Log.i(TAG, "onSuccess: 返回数据"); |
679 | } | 680 | } |
680 | 681 | ||
681 | @Override | 682 | @Override |
682 | public void onCancel() { | 683 | public void onCancel() { |
683 | Log.i(TAG, "onCancel: 取消"); | 684 | Log.i(TAG, "onCancel: 取消"); |
684 | } | 685 | } |
685 | 686 | ||
686 | @Override | 687 | @Override |
687 | public void onFinish(List<ImageInfo> selectImage) { | 688 | public void onFinish(List<ImageInfo> selectImage) { |
688 | if (selectImage.size() == photoList.size()) { | 689 | if (selectImage.size() == photoList.size()) { |
689 | List<String> strings = new ArrayList<>(); | 690 | List<String> strings = new ArrayList<>(); |
690 | Intent intent = new Intent(context, ImageActivity.class); | 691 | Intent intent = new Intent(context, ImageActivity.class); |
691 | for (ImageInfo imageInfo : selectImage) { | 692 | for (ImageInfo imageInfo : selectImage) { |
692 | strings.add(imageInfo.getPath()); | 693 | strings.add(imageInfo.getPath()); |
693 | } | 694 | } |
694 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 695 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
695 | startActivity(intent); | 696 | startActivity(intent); |
696 | } | 697 | } |
697 | } | 698 | } |
698 | 699 | ||
699 | @Override | 700 | @Override |
700 | public void onError() { | 701 | public void onError() { |
701 | Log.i(TAG, "onError: 出错"); | 702 | Log.i(TAG, "onError: 出错"); |
702 | } | 703 | } |
703 | } | 704 | } |
704 | 705 | ||
705 | @Override | 706 | @Override |
706 | protected void onResume() { | 707 | protected void onResume() { |
707 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 708 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
708 | try { | 709 | try { |
709 | studentBean = new Gson().fromJson(student, StudentBean.class); | 710 | studentBean = new Gson().fromJson(student, StudentBean.class); |
710 | } catch (Exception e) { | 711 | } catch (Exception e) { |
711 | 712 | ||
712 | } | 713 | } |
713 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); | 714 | binding.tvTitle.setText(studentBean.getStuName() + "的错题本"); |
714 | refreshError(); | 715 | refreshError(); |
715 | super.onResume(); | 716 | super.onResume(); |
716 | } | 717 | } |
717 | } | 718 | } |
718 | 719 |