Commit ea57c8d609700b40fa515a2d7c64cabd95c87ce9

Authored by shixianjie
1 parent bd79e76cdd
Exists in master

周总结和阶段性总结列表展示

.idea/deploymentTargetDropDown.xml
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="deploymentTargetDropDown"> 3 <component name="deploymentTargetDropDown">
4 <value> 4 <value>
5 <entry key="app"> 5 <entry key="app">
6 <State /> 6 <State>
7 <runningDeviceTargetSelectedWithDropDown>
8 <Target>
9 <type value="RUNNING_DEVICE_TARGET" />
10 <deviceKey>
11 <Key>
12 <type value="SERIAL_NUMBER" />
13 <value value="192.168.3.176:35119" />
14 </Key>
15 </deviceKey>
16 </Target>
17 </runningDeviceTargetSelectedWithDropDown>
18 <timeTargetWasSelectedWithDropDown value="2024-10-09T03:21:59.277023400Z" />
19 </State>
7 </entry> 20 </entry>
8 </value> 21 </value>
9 </component> 22 </component>
10 </project> 23 </project>
app/src/main/java/com/hjx/parent/StuHomeworkActivity.java
1 package com.hjx.parent; 1 package com.hjx.parent;
2 2
3 import android.annotation.SuppressLint; 3 import android.annotation.SuppressLint;
4 import android.content.Intent; 4 import android.content.Intent;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.view.Gravity;
7 import android.view.View;
8 import android.widget.ImageView;
6 import android.widget.LinearLayout; 9 import android.widget.LinearLayout;
10 import android.widget.PopupMenu;
7 import android.widget.PopupWindow; 11 import android.widget.PopupWindow;
12 import android.widget.TextView;
8 13
14 import androidx.annotation.NonNull;
9 import androidx.annotation.Nullable; 15 import androidx.annotation.Nullable;
10 import androidx.lifecycle.MutableLiveData; 16 import androidx.lifecycle.MutableLiveData;
11 17
18 import com.chad.library.adapter.base.BaseQuickAdapter;
19 import com.chad.library.adapter.base.BaseViewHolder;
20 import com.google.android.material.tabs.TabLayout;
12 import com.google.gson.Gson; 21 import com.google.gson.Gson;
13 import com.hjx.parent.adapter.HomeworkListAdapter; 22 import com.hjx.parent.adapter.HomeworkListAdapter;
14 import com.hjx.parent.databinding.ActivityStudentHomeworkBinding; 23 import com.hjx.parent.databinding.ActivityStudentHomeworkBinding;
15 import com.hjx.parent.databinding.PopupFilterFeedbackBinding; 24 import com.hjx.parent.databinding.PopupFilterFeedbackBinding;
16 import com.hjx.parent.databinding.PopupFilterGradeBinding; 25 import com.hjx.parent.databinding.PopupFilterGradeBinding;
17 import com.hjx.parent.databinding.PopupFilterSubjectBinding; 26 import com.hjx.parent.databinding.PopupFilterSubjectBinding;
18 import com.hjx.parent.databinding.PopupFilterTermBinding; 27 import com.hjx.parent.databinding.PopupFilterTermBinding;
19 import com.hjx.parent.dialog.MsgConfirmDialog; 28 import com.hjx.parent.dialog.MsgConfirmDialog;
29 import com.hjx.parent.dialog.StageHuyouDialog;
30 import com.hjx.parent.function.Function1;
20 import com.hjx.parent.rx.BaseRxActivity; 31 import com.hjx.parent.rx.BaseRxActivity;
32 import com.prws.common.bean.ResponseResult;
21 import com.prws.common.bean.Student; 33 import com.prws.common.bean.Student;
22 import com.prws.common.bean.homework.HomeworkList; 34 import com.prws.common.bean.homework.HomeworkList;
35 import com.prws.common.bean.homework.StDetail;
23 import com.prws.common.net.NetWorks; 36 import com.prws.common.net.NetWorks;
24 import com.prws.common.utils.SharedPreferencesUtil; 37 import com.prws.common.utils.SharedPreferencesUtil;
25 import com.trello.rxlifecycle2.android.RxLifecycleAndroid; 38 import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
26 39
40 import java.text.DecimalFormat;
41 import java.text.SimpleDateFormat;
42 import java.util.ArrayList;
43 import java.util.Calendar;
27 import java.util.Collections; 44 import java.util.Collections;
45 import java.util.Date;
46 import java.util.HashMap;
47 import java.util.List;
48 import java.util.Locale;
49 import java.util.Map;
28 50
29 import io.reactivex.Observable; 51 import io.reactivex.Observable;
30 import io.reactivex.android.schedulers.AndroidSchedulers; 52 import io.reactivex.android.schedulers.AndroidSchedulers;
31 import io.reactivex.schedulers.Schedulers; 53 import io.reactivex.schedulers.Schedulers;
32 54
33 public class StuHomeworkActivity extends BaseRxActivity<ActivityStudentHomeworkBinding> { 55 public class StuHomeworkActivity extends BaseRxActivity<ActivityStudentHomeworkBinding> {
34 56
35 private final HomeworkListAdapter homeworkAdapter = new HomeworkListAdapter(); 57 private final HomeworkListAdapter homeworkAdapter = new HomeworkListAdapter();
36 58
59 private final List<StDetail> mWeekList = new ArrayList<>();
60 private final List<StDetail> mStageList = new ArrayList<>();
61 private final HuyouAdapter weekAdapter = new HuyouAdapter(mWeekList);
62 private final HuyouAdapter stageAdapter = new HuyouAdapter(mStageList);
63
37 PopupWindow subjectFilter, gradeFilter, termFilter, feedbackFilter; 64 PopupWindow subjectFilter, gradeFilter, termFilter, feedbackFilter;
38 MsgConfirmDialog deleteDialog; 65 MsgConfirmDialog deleteDialog;
66 StageHuyouDialog stageHuyouDialog;
39 State state = new State(); 67 State state = new State();
40 68
41 private void handlerIntent() { 69 private void handlerIntent() {
42 String json = getIntent().getStringExtra("studentJson"); 70 String json = getIntent().getStringExtra("studentJson");
43 if (json == null) json = (String) SharedPreferencesUtil.getData("student", ""); 71 if (json == null) json = (String) SharedPreferencesUtil.getData("student", "");
44 try { state.student = new Gson().fromJson(json, Student.class); } 72 try { state.student = new Gson().fromJson(json, Student.class); }
45 catch (Throwable t) { t.printStackTrace(); } 73 catch (Throwable t) { t.printStackTrace(); }
46 } 74 }
47 75
48 @SuppressLint("SetTextI18n") 76 @SuppressLint("SetTextI18n")
49 @Override 77 @Override
50 public void initView(Bundle savedInstanceState) { 78 public void initView(Bundle savedInstanceState) {
51 handlerIntent(); 79 handlerIntent();
52 if (state.student == null) { 80 if (state.student == null) {
53 finish(); 81 finish();
54 return; 82 return;
55 } 83 }
56 binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); 84 binding.toolbar.setNavigationOnClickListener(v -> onBackPressed());
57 binding.tvTitle.setText(state.student.stuName + "的全部作业"); 85 binding.tvTitle.setText(state.student.stuName + "的全部作业");
58 86 setupTab();
59 binding.recyclerView.setAdapter(homeworkAdapter); 87 binding.recyclerView.setAdapter(homeworkAdapter);
60 88
61 binding.ftSubject.setOnClickListener(v -> showSubjectFilter()); 89 binding.ftSubject.setOnClickListener(v -> showSubjectFilter());
62 binding.ftGrade.setOnClickListener(v -> showGradeFilter()); 90 binding.ftGrade.setOnClickListener(v -> showGradeFilter());
63 binding.ftTerm.setOnClickListener(v -> showTermFilter()); 91 binding.ftTerm.setOnClickListener(v -> showTermFilter());
64 binding.ftFeedback.setOnClickListener(v -> showFeedbackFilter()); 92 binding.ftFeedback.setOnClickListener(v -> showFeedbackFilter());
65 homeworkAdapter.deleteCall = data -> { 93 homeworkAdapter.deleteCall = data -> {
66 if (deleteDialog == null) { 94 if (deleteDialog == null) {
67 deleteDialog = new MsgConfirmDialog.Builder(this) 95 deleteDialog = new MsgConfirmDialog.Builder(this)
68 .setMessage("确认要删除吗?一旦删除不可恢复") 96 .setMessage("确认要删除吗?一旦删除不可恢复")
69 .setPositive("暂不删除") 97 .setPositive("暂不删除")
70 .setNegative("确定删除") 98 .setNegative("确定删除")
71 .build(); 99 .build();
72 } 100 }
73 deleteDialog.show(() -> { 101 deleteDialog.show(() -> {
74 deleteHomework(data); 102 deleteHomework(data);
75 return true; 103 return true;
76 }, null); 104 }, null);
77 }; 105 };
78 homeworkAdapter.detailCall = data -> { 106 homeworkAdapter.detailCall = data -> {
79 if (data.getRight() == null) { 107 if (data.getRight() == null) {
80 Intent intent = new Intent(this, HomeworkDetailActivity.class); 108 Intent intent = new Intent(this, HomeworkDetailActivity.class);
81 intent.putExtra("data", data); 109 intent.putExtra("data", data);
82 intent.putExtra("student", state.student); 110 intent.putExtra("student", state.student);
83 startActivity(intent); 111 startActivity(intent);
84 } else { 112 } else {
85 Intent intent = new Intent(this, HomeworkShareActivity.class); 113 Intent intent = new Intent(this, HomeworkShareActivity.class);
86 intent.putExtra("student", state.student); 114 intent.putExtra("student", state.student);
87 intent.putExtra("id", data.getId()); 115 intent.putExtra("id", data.getId());
88 intent.putExtra("grade", data.getGrade()); 116 intent.putExtra("grade", data.getGrade());
89 intent.putExtra("subject", data.getSubject()); 117 intent.putExtra("subject", data.getSubject());
90 startActivity(intent); 118 startActivity(intent);
91 } 119 }
92 }; 120 };
93 121
94 binding.btnChangeStudent.setOnClickListener(v -> { 122 binding.btnChangeStudent.setOnClickListener(v -> {
95 Intent intent = new Intent(this, TeacherChooseActivity.class); 123 Intent intent = new Intent(this, TeacherChooseActivity.class);
96 intent.putExtra("needBack", true); 124 intent.putExtra("needBack", true);
97 startActivityForResult(intent, 0xA01); 125 startActivityForResult(intent, 0xA01);
98 }); 126 });
127
128 binding.btnGeneralHuyou.setOnClickListener(v -> generalWeek());
129 binding.btnStageHuyou.setOnClickListener(v -> {
130 if (stageHuyouDialog == null) stageHuyouDialog = new StageHuyouDialog(this);
131 stageHuyouDialog.show(this::generalStage);
132 });
133
134 getWeekHuyou();
135 getStageHuyou();
99 } 136 }
100 137
101 @Override 138 @Override
102 protected void onStart() { 139 protected void onStart() {
103 super.onStart(); 140 super.onStart();
104 getHomework(); 141 getHomework();
105 } 142 }
106 143
107 @SuppressLint("SetTextI18n") 144 @SuppressLint("SetTextI18n")
108 @Override 145 @Override
109 protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { 146 protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
110 super.onActivityResult(requestCode, resultCode, data); 147 super.onActivityResult(requestCode, resultCode, data);
111 if (requestCode == 0xA01 && resultCode == RESULT_OK) { 148 if (requestCode == 0xA01 && resultCode == RESULT_OK) {
112 String json = (String) SharedPreferencesUtil.getData("student", ""); 149 String json = (String) SharedPreferencesUtil.getData("student", "");
113 try { 150 try {
114 state.student = new Gson().fromJson(json, Student.class); 151 state.student = new Gson().fromJson(json, Student.class);
115 binding.tvTitle.setText(state.student.stuName + "的全部作业"); 152 binding.tvTitle.setText(state.student.stuName + "的全部作业");
116 getHomework(); 153 getHomework();
154 getWeekHuyou();
155 getStageHuyou();
117 } 156 }
118 catch (Throwable t) { t.printStackTrace(); } 157 catch (Throwable t) { t.printStackTrace(); }
119 } 158 }
120 } 159 }
121 160
161 private void setupTab() {
162 binding.tabLayout.addTab(binding.tabLayout.newTab().setText("每日作业"));
163 binding.tabLayout.addTab(binding.tabLayout.newTab().setText("每周总结"));
164 binding.tabLayout.addTab(binding.tabLayout.newTab().setText("阶段性总结"));
165 binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
166 @Override
167 public void onTabSelected(TabLayout.Tab tab) {
168 binding.filterBar.setVisibility(View.GONE);
169 binding.weekBar.setVisibility(View.GONE);
170 binding.stageBar.setVisibility(View.GONE);
171 if (tab.getPosition() == 0) { //每日
172 binding.filterBar.setVisibility(View.VISIBLE);
173 binding.recyclerView.setAdapter(homeworkAdapter);
174 } else if (tab.getPosition() == 1) { //每周
175 binding.weekBar.setVisibility(View.VISIBLE);
176 binding.recyclerView.setAdapter(weekAdapter);
177 } else if (tab.getPosition() == 2) { //阶段
178 binding.stageBar.setVisibility(View.VISIBLE);
179 binding.recyclerView.setAdapter(stageAdapter);
180 }
181 }
182 @Override
183 public void onTabUnselected(TabLayout.Tab tab) {
184 }
185 @Override
186 public void onTabReselected(TabLayout.Tab tab) {
187 }
188 });
189 }
190
122 @SuppressLint("CheckResult") 191 @SuppressLint("CheckResult")
123 protected void deleteHomework(HomeworkList data) { 192 protected void deleteHomework(HomeworkList data) {
124 NetWorks.service_url.deleteHomework(NetWorks.getHeader(), data.getId()) 193 NetWorks.service_url.deleteHomework(NetWorks.getHeader(), data.getId())
125 .subscribeOn(Schedulers.io()) 194 .subscribeOn(Schedulers.io())
126 .observeOn(AndroidSchedulers.mainThread()) 195 .observeOn(AndroidSchedulers.mainThread())
127 .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) 196 .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle()))
128 .subscribe((response, th) -> { 197 .subscribe((response, th) -> {
129 if (th != null) th.printStackTrace(); 198 if (th != null) th.printStackTrace();
130 if (response != null && response.getSuccess()) { 199 if (response != null && response.getSuccess()) {
131 getHomework(); 200 getHomework();
132 } 201 }
133 }); 202 });
134 203
135 } 204 }
136 205
137 @SuppressLint("CheckResult") 206 @SuppressLint("CheckResult")
138 protected void getHomework() { 207 protected void getHomework() {
139 NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), state.student.stuId) 208 NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), state.student.stuId)
140 .subscribeOn(Schedulers.io()) 209 .subscribeOn(Schedulers.io())
141 .observeOn(AndroidSchedulers.mainThread()) 210 .observeOn(AndroidSchedulers.mainThread())
142 .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) 211 .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle()))
143 .toObservable() 212 .toObservable()
144 .flatMap(response -> Observable.fromIterable(response.getData())) 213 .flatMap(response -> Observable.fromIterable(response.getData()))
145 // 过滤 214 // 过滤
146 .filter(data -> { // 学科 215 .filter(data -> { // 学科
147 String subject = state.subject.getValue(); 216 String subject = state.subject.getValue();
148 if (subject == null || subject.isEmpty()) return true; 217 if (subject == null || subject.isEmpty()) return true;
149 else return subject.equals(data.getSubject()); 218 else return subject.equals(data.getSubject());
150 }) 219 })
151 .filter(data -> { // 年级 220 .filter(data -> { // 年级
152 String grade = state.grade.getValue(); 221 String grade = state.grade.getValue();
153 if (grade == null || grade.isEmpty()) return true; 222 if (grade == null || grade.isEmpty()) return true;
154 else return grade.equals(data.getGrade()); 223 else return grade.equals(data.getGrade());
155 }) 224 })
156 .filter(data -> { // 学期 225 .filter(data -> { // 学期
157 String term = state.term.getValue(); 226 String term = state.term.getValue();
158 if (term == null || term.isEmpty()) return true; 227 if (term == null || term.isEmpty()) return true;
159 else return term.equals(data.getTerm()); 228 else return term.equals(data.getTerm());
160 }) 229 })
161 .filter(data -> { // 反馈 230 .filter(data -> { // 反馈
162 Integer feedback = state.feedback.getValue(); 231 Integer feedback = state.feedback.getValue();
163 if (feedback == null || feedback == 0) return true; 232 if (feedback == null || feedback == 0) return true;
164 else return (feedback == 1 && data.getRight() != null) || (feedback == 2 && data.getRight() == null); 233 else return (feedback == 1 && data.getRight() != null) || (feedback == 2 && data.getRight() == null);
165 }) 234 })
166 // 过滤完成, 收集 235 // 过滤完成, 收集
167 .toList() 236 .toList()
168 .subscribe((data, th) -> { 237 .subscribe((data, th) -> {
169 if (th != null) th.printStackTrace(); 238 if (th != null) th.printStackTrace();
170 if (data != null) { 239 if (data != null) {
171 Collections.sort(data); 240 Collections.sort(data);
172 } 241 }
173 homeworkAdapter.setNewData(data); 242 homeworkAdapter.setNewData(data);
174 }); 243 });
175 } 244 }
176 245
246 @SuppressLint({"CheckResult", "NotifyDataSetChanged"})
247 private void getWeekHuyou() {
248 NetWorks.service_url.getHuyouList(NetWorks.getHeader(), state.student.stuId, 0)
249 .compose(transformSingle())
250 .map(ResponseResult::getData)
251 .subscribe((list, throwable) -> {
252 if (throwable != null) {
253 throwable.printStackTrace();
254 return;
255 }
256 if (list != null) {
257 mWeekList.clear();
258 mWeekList.addAll(list);
259 weekAdapter.notifyDataSetChanged();
260
261 boolean exist = false;
262 int thisWeek = Calendar.getInstance().get(Calendar.WEEK_OF_YEAR);
263 for (StDetail bean: mWeekList) {
264 Calendar other = Calendar.getInstance();
265 other.setTime(bean.endTime);
266 if (other.get(Calendar.WEEK_OF_YEAR) == thisWeek) {
267 exist = true;
268 break;
269 }
270 }
271 binding.btnGeneralHuyou.setVisibility(exist ? View.GONE : View.VISIBLE);
272 }
273 });
274 }
275
276 @SuppressLint({"CheckResult", "NotifyDataSetChanged"})
277 private void getStageHuyou() {
278 NetWorks.service_url.getHuyouList(NetWorks.getHeader(), state.student.stuId, 1)
279 .compose(transformSingle())
280 .map(ResponseResult::getData)
281 .subscribe((list, throwable) -> {
282 if (throwable != null) {
283 throwable.printStackTrace();
284 return;
285 }
286 if (list != null) {
287 mStageList.clear();
288 mStageList.addAll(list);
289 stageAdapter.notifyDataSetChanged();
290 }
291 });
292 }
293
294 @SuppressLint("CheckResult")
295 private void generalWeek() {
296 showLoadingDialog("稍等...");
297 NetWorks.service_url.generalHuyou()
298 .compose(transformSingle())
299 .subscribe((response, throwable) -> {
300 cancelLoadingDialog();
301 if (throwable != null) {
302 loadFail("失败");
303 throwable.printStackTrace();
304 return;
305 }
306 if (response != null && response.getSuccess()) {
307 binding.btnGeneralHuyou.setVisibility(View.GONE);
308 getWeekHuyou();
309 }
310 });
311 }
312
313 @SuppressLint("CheckResult")
314 private void generalStage(Date startDate, Date endDate, String subject) {
315 SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd HH:mm:ss", Locale.CHINA);
316 Map<String, Object> body = new HashMap<>();
317 body.put("stuId", state.student.stuId);
318 body.put("startTime", format.format(startDate));
319 body.put("endTime", format.format(endDate));
320 body.put("subject", subject);
321 showLoadingDialog("稍等...");
322 NetWorks.service_url.generalStageHuyou(NetWorks.getHeader(), body)
323 .subscribeOn(Schedulers.io())
324 .observeOn(AndroidSchedulers.mainThread())
325 .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle()))
326 .subscribe((response, throwable) -> {
327 if (throwable != null) {
328 loadFail("失败");
329 throwable.printStackTrace();
330 return;
331 }
332 if (response.getSuccess()) {
333 getStageHuyou();
334 cancelLoadingDialog();
335 } else {
336 loadFail(response.getMsg());
337 }
338 });
339 }
340
177 private void showSubjectFilter() { 341 private void showSubjectFilter() {
178 if (subjectFilter == null) { 342 if (subjectFilter == null) {
179 PopupFilterSubjectBinding db = PopupFilterSubjectBinding.inflate(getLayoutInflater()); 343 PopupFilterSubjectBinding db = PopupFilterSubjectBinding.inflate(getLayoutInflater());
180 db.setLifecycleOwner(this); 344 db.setLifecycleOwner(this);
181 db.setState(state); 345 db.setState(state);
182 db.bg.setOnClickListener(v -> subjectFilter.dismiss()); 346 db.bg.setOnClickListener(v -> subjectFilter.dismiss());
183 subjectFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 347 subjectFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
184 subjectFilter.setOutsideTouchable(true); 348 subjectFilter.setOutsideTouchable(true);
185 subjectFilter.setOnDismissListener(this::getHomework); 349 subjectFilter.setOnDismissListener(this::getHomework);
186 } 350 }
187 subjectFilter.showAsDropDown(binding.anchorView); 351 subjectFilter.showAsDropDown(binding.anchorView);
188 } 352 }
189 353
190 private void showGradeFilter() { 354 private void showGradeFilter() {
191 if (gradeFilter == null) { 355 if (gradeFilter == null) {
192 PopupFilterGradeBinding db = PopupFilterGradeBinding.inflate(getLayoutInflater()); 356 PopupFilterGradeBinding db = PopupFilterGradeBinding.inflate(getLayoutInflater());
193 db.setLifecycleOwner(this); 357 db.setLifecycleOwner(this);
194 db.setState(state); 358 db.setState(state);
195 db.bg.setOnClickListener(v -> gradeFilter.dismiss()); 359 db.bg.setOnClickListener(v -> gradeFilter.dismiss());
196 gradeFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 360 gradeFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
197 gradeFilter.setOutsideTouchable(true); 361 gradeFilter.setOutsideTouchable(true);
198 gradeFilter.setOnDismissListener(this::getHomework); 362 gradeFilter.setOnDismissListener(this::getHomework);
199 } 363 }
200 gradeFilter.showAsDropDown(binding.anchorView); 364 gradeFilter.showAsDropDown(binding.anchorView);
201 } 365 }
202 366
203 private void showTermFilter() { 367 private void showTermFilter() {
204 if (termFilter == null) { 368 if (termFilter == null) {
205 PopupFilterTermBinding db = PopupFilterTermBinding.inflate(getLayoutInflater()); 369 PopupFilterTermBinding db = PopupFilterTermBinding.inflate(getLayoutInflater());
206 db.setLifecycleOwner(this); 370 db.setLifecycleOwner(this);
207 db.setState(state); 371 db.setState(state);
208 db.bg.setOnClickListener(v -> termFilter.dismiss()); 372 db.bg.setOnClickListener(v -> termFilter.dismiss());
209 termFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 373 termFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
210 termFilter.setOutsideTouchable(true); 374 termFilter.setOutsideTouchable(true);
211 termFilter.setOnDismissListener(this::getHomework); 375 termFilter.setOnDismissListener(this::getHomework);
212 } 376 }
213 termFilter.showAsDropDown(binding.anchorView); 377 termFilter.showAsDropDown(binding.anchorView);
214 } 378 }
215 379
216 private void showFeedbackFilter() { 380 private void showFeedbackFilter() {
217 if (feedbackFilter == null) { 381 if (feedbackFilter == null) {
218 PopupFilterFeedbackBinding db = PopupFilterFeedbackBinding.inflate(getLayoutInflater()); 382 PopupFilterFeedbackBinding db = PopupFilterFeedbackBinding.inflate(getLayoutInflater());
219 db.setLifecycleOwner(this); 383 db.setLifecycleOwner(this);
220 db.setState(state); 384 db.setState(state);
221 db.bg.setOnClickListener(v -> feedbackFilter.dismiss()); 385 db.bg.setOnClickListener(v -> feedbackFilter.dismiss());
222 feedbackFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 386 feedbackFilter = new PopupWindow(db.getRoot(), LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
223 feedbackFilter.setOutsideTouchable(true); 387 feedbackFilter.setOutsideTouchable(true);
224 feedbackFilter.setOnDismissListener(this::getHomework); 388 feedbackFilter.setOnDismissListener(this::getHomework);
225 } 389 }
226 feedbackFilter.showAsDropDown(binding.anchorView); 390 feedbackFilter.showAsDropDown(binding.anchorView);
227 } 391 }
228 392
229 @Override 393 @Override
230 protected ActivityStudentHomeworkBinding getViewBinding() { 394 protected ActivityStudentHomeworkBinding getViewBinding() {
231 return ActivityStudentHomeworkBinding.inflate(getLayoutInflater()); 395 return ActivityStudentHomeworkBinding.inflate(getLayoutInflater());
232 } 396 }
233 397
234 public static class State { 398 public static class State {
235 public Student student; 399 public Student student;
236 400
237 public MutableLiveData<String> subject = new MutableLiveData<>(""); 401 public MutableLiveData<String> subject = new MutableLiveData<>("");
238 public void setSubject(String value) { 402 public void setSubject(String value) {
239 subject.setValue(value); 403 subject.setValue(value);
240 } 404 }
241 405
242 public MutableLiveData<String> grade = new MutableLiveData<>(""); 406 public MutableLiveData<String> grade = new MutableLiveData<>("");
243 public void setGrade(String value) { 407 public void setGrade(String value) {
244 grade.setValue(value); 408 grade.setValue(value);
245 } 409 }
246 410
247 public MutableLiveData<String> term = new MutableLiveData<>(""); 411 public MutableLiveData<String> term = new MutableLiveData<>("");
248 public void setTerm(String value) { 412 public void setTerm(String value) {
249 term.setValue(value); 413 term.setValue(value);
250 } 414 }
251 415
252 //0:全部, 1: 已反馈, 2:未反馈 416 //0:全部, 1: 已反馈, 2:未反馈
253 public MutableLiveData<Integer> feedback = new MutableLiveData<>(0); 417 public MutableLiveData<Integer> feedback = new MutableLiveData<>(0);
254 public void setFeedback(int value) { 418 public void setFeedback(int value) {
255 feedback.setValue(value); 419 feedback.setValue(value);
256 } 420 }
257 } 421 }
422
423 static class HuyouAdapter extends BaseQuickAdapter<StDetail, BaseViewHolder> {
424 public Function1<StDetail> deleteCall;
425 public Student student;
426
427 public HuyouAdapter(@Nullable List<StDetail> data) {
428 super(R.layout.item_homework_list, data);
429 }
430
431 @SuppressLint("SetTextI18n,SimpleDateFormat")
432 @Override
433 protected void convert(@NonNull BaseViewHolder holder, StDetail data) {
434 holder.setGone(R.id.tvFlag, false);
435 int subjectImg;
436 switch (data.homeworkSubject) {
437 case "语文":
438 subjectImg = R.drawable.ic_chinese;
439 break;
440 case "英语":
441 subjectImg = R.drawable.ic_english;
442 break;
443 case "物理":
444 subjectImg = R.drawable.ic_physics;
445 break;
446 case "化学":
447 subjectImg = R.drawable.ic_chemistry;
448 break;
449 case "数学":
450 default:
451 subjectImg = R.drawable.ic_math;
452 }
453 holder.setImageResource(R.id.ivSubject, subjectImg);
454 Date endDate = new Date(data.endTime.getTime() - 1000);
455 String startStr = new SimpleDateFormat("yyyy.M.d").format(data.startTime);
456 String endStr = new SimpleDateFormat("-M.d").format(endDate);
457 String typeStr = data.type == 0 ? "作业周总结" : "作业阶段性总结";
458 String title = startStr + endStr + data.homeworkSubject + typeStr;
459 holder.setText(R.id.tvName, title);
460 holder.setText(R.id.tvGrade, data.grade);
461 }
462
463 private SimpleDateFormat getFormatWithGmt8(String pattern) {
464 SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA);
465 //format.setTimeZone(TimeZone.getTimeZone("GMT+16"));
466 return format;
467 }
468 }
469
258 } 470 }
259 471
app/src/main/java/com/hjx/parent/dialog/StageHuyouDialog.java
File was created 1 package com.hjx.parent.dialog;
2
3 import android.content.Context;
4 import android.view.View;
5 import android.widget.RadioButton;
6 import android.widget.Toast;
7
8 import androidx.annotation.NonNull;
9
10 import com.bigkoo.pickerview.builder.TimePickerBuilder;
11 import com.bigkoo.pickerview.view.TimePickerView;
12 import com.hjx.parent.databinding.DialogStageHuyouBinding;
13 import com.hjx.parent.function.Function3;
14
15 import java.text.SimpleDateFormat;
16 import java.util.Date;
17
18 public class StageHuyouDialog extends BaseDialog<DialogStageHuyouBinding>{
19
20 Function3<Date, Date, String> callback;
21 Date startDate;
22 Date endDate;
23
24 public StageHuyouDialog(Context context) {
25 super(context);
26 }
27
28 @Override
29 public void initView() {
30 super.initView();
31 RadioButton firstRb = (RadioButton) binding.rgSubject.getChildAt(0);
32 firstRb.setChecked(true);
33 binding.btnClose.setOnClickListener(v -> {
34 dismiss();
35 });
36 binding.tvStart.setOnClickListener(v -> {
37 TimePickerView pickerView = new TimePickerBuilder(getContext(), (date, p) -> {
38 long t = date.getTime();
39 long day = 24 * 60 * 60 * 1000;
40 long h8 = 8 * 60 * 60 * 1000;
41 startDate = new Date(t / day * day - h8);
42 binding.tvStart.setText(new SimpleDateFormat("yyyy-MM-dd").format(startDate));
43 }).setType(new boolean[] {true, true, true, false, false, false}).isDialog(true).build();
44 pickerView.show();
45 });
46 binding.tvEnd.setOnClickListener(v -> {
47 TimePickerView pickerView = new TimePickerBuilder(getContext(), (date, p) -> {
48 long t = date.getTime();
49 long day = 24 * 60 * 60 * 1000;
50 long h8 = 8 * 60 * 60 * 1000;
51 endDate = new Date(t / day * day - h8 + day - 1000);
52 binding.tvEnd.setText(new SimpleDateFormat("yyyy-MM-dd").format(endDate));
53 }).setType(new boolean[] {true, true, true, false, false, false}).isDialog(true).build();
54 pickerView.show();
55 });
56 binding.btnConfirm.setOnClickListener(v -> {
57 if (startDate == null) {
58 Toast.makeText(getContext(), "请先设置开始时间和截止时间。", Toast.LENGTH_SHORT).show();
59 return;
60 }
61 if (endDate == null) {
62 Toast.makeText(getContext(), "请先设置开始时间和截止时间。", Toast.LENGTH_SHORT).show();
63 return;
64 }
65 if (endDate.before(startDate)) {
66 Toast.makeText(getContext(), "结束时间不能早于开始时间", Toast.LENGTH_SHORT).show();
67 return;
68 }
69 String subject = "";
70 for (int i = 0; i < binding.rgSubject.getChildCount(); i++) {
71 View view = binding.rgSubject.getChildAt(i);
72 if (!(view instanceof RadioButton)) {
73 continue;
74 }
75 RadioButton rb = (RadioButton) view;
76 if (rb.isChecked()) {
77 subject = rb.getText().toString();
78 break;
79 }
80 }
81 if (callback != null) callback.invoke(startDate, endDate, subject);
82 dismiss();
83 });
84 }
85
86 public void show(Function3<Date, Date, String> callback) {
87 this.callback = callback;
88 super.show();
89 }
90
91 @NonNull
92 @Override
93 public DialogStageHuyouBinding getBinding() {
94 return DialogStageHuyouBinding.inflate(getLayoutInflater());
95 }
96 }
97
app/src/main/res/color/color_huyou_subject_select.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <selector xmlns:android="http://schemas.android.com/apk/res/android">
3 <item android:color="@color/white" android:state_checked="true"/>
4 <item android:color="#333"/>
5 </selector>
app/src/main/res/drawable/bg_huyou_time_select.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android">
3
4 <corners android:radius="4dp"/>
5 <stroke android:width="1dp" android:color="#ccc"/>
6
7 </shape>
app/src/main/res/drawable/btn_general_huyou.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android">
3
4 <corners android:radius="12dp"/>
5 <stroke android:color="#1C90F3" android:width="1dp" android:dashWidth="6dp" android:dashGap="3dp"/>
6
7 </shape>
app/src/main/res/drawable/btn_huyou_subject_select.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <selector xmlns:android="http://schemas.android.com/apk/res/android">
3
4 <item android:state_checked="true">
5 <shape>
6 <corners android:radius="88dp"/>
7 <solid android:color="#489AFA"/>
8 </shape>
9 </item>
10
11 <item>
12 <shape>
13 <corners android:radius="88dp"/>
14 <solid android:color="#F5F5F5"/>
15 </shape>
16 </item>
17
18 </selector>
app/src/main/res/drawable/svg_close_24.xml
File was created 1 <vector xmlns:android="http://schemas.android.com/apk/res/android"
2 android:width="24dp"
3 android:height="24dp"
4 android:viewportWidth="24"
5 android:viewportHeight="24">
6 <path
7 android:pathData="M22.482,4.316L14.748,11.686L22.477,19.05C23.235,19.772 23.235,20.942 22.477,21.664L22.134,21.991C21.377,22.713 20.148,22.713 19.391,21.991L11.846,14.802L4.302,21.991C3.544,22.713 2.316,22.713 1.558,21.991L1.215,21.664C0.457,20.942 0.457,19.772 1.215,19.05L8.949,11.681L1.22,4.316C0.462,3.594 0.462,2.424 1.22,1.702L1.563,1.375C2.321,0.653 3.549,0.653 4.307,1.375L11.851,8.564L19.396,1.375C20.153,0.653 21.382,0.653 22.139,1.375L22.482,1.702C23.24,2.424 23.24,3.594 22.482,4.316Z"
8 android:fillColor="#333333"
9 android:fillType="evenOdd"/>
10 </vector>
11
app/src/main/res/layout/activity_student_homework.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
5 android:orientation="vertical" 5 android:orientation="vertical"
6 android:layout_width="match_parent" 6 android:layout_width="match_parent"
7 android:layout_height="match_parent" 7 android:layout_height="match_parent"
8 tools:ignore="HardcodedText"> 8 tools:ignore="HardcodedText">
9 9
10 <androidx.appcompat.widget.Toolbar 10 <androidx.appcompat.widget.Toolbar
11 android:id="@+id/toolbar" 11 android:id="@+id/toolbar"
12 app:navigationIcon="@drawable/svg_back" 12 app:navigationIcon="@drawable/svg_back"
13 android:paddingStart="-8dp" 13 android:paddingStart="-8dp"
14 android:paddingEnd="-8dp" 14 android:paddingEnd="-8dp"
15 android:background="@color/white" 15 android:background="@color/white"
16 android:layout_width="match_parent" 16 android:layout_width="match_parent"
17 android:layout_height="40dp"> 17 android:layout_height="40dp">
18 <TextView 18 <TextView
19 android:id="@+id/tvTitle" 19 android:id="@+id/tvTitle"
20 tools:text="小明的全部作业" 20 tools:text="小明的全部作业"
21 android:textSize="18sp" 21 android:textSize="18sp"
22 android:textColor="#333" 22 android:textColor="#333"
23 android:textStyle="bold" 23 android:textStyle="bold"
24 android:layout_gravity="center" 24 android:layout_gravity="center"
25 android:layout_width="wrap_content" 25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content"/> 26 android:layout_height="wrap_content"/>
27 <ImageView 27 <ImageView
28 android:id="@+id/btnChangeStudent" 28 android:id="@+id/btnChangeStudent"
29 android:src="@drawable/png_ic_change_student" 29 android:src="@drawable/png_ic_change_student"
30 android:layout_gravity="end" 30 android:layout_gravity="end"
31 android:layout_marginEnd="24dp" 31 android:layout_marginEnd="24dp"
32 android:layout_width="20dp" 32 android:layout_width="20dp"
33 android:layout_height="20dp"/> 33 android:layout_height="20dp"/>
34 </androidx.appcompat.widget.Toolbar> 34 </androidx.appcompat.widget.Toolbar>
35 <com.google.android.material.tabs.TabLayout
36 android:id="@+id/tabLayout"
37 app:tabMode="fixed"
38 app:tabGravity="fill"
39 app:tabTextColor="#333333"
40 app:tabSelectedTextColor="#1C90F3"
41 app:tabIndicatorColor="#1C90F3"
42 app:tabIndicatorHeight="2dp"
43 app:tabIndicatorFullWidth="false"
44 app:tabTextAppearance="@style/tab_homework"
45 app:tabRippleColor="@color/transparent"
46 android:background="@color/white"
47 android:layout_width="match_parent"
48 android:layout_height="45dp"/>
35 <LinearLayout 49 <LinearLayout
50 android:id="@+id/filterBar"
51 tools:visibility="gone"
36 android:orientation="horizontal" 52 android:orientation="horizontal"
37 android:background="@color/white" 53 android:background="@color/white"
38 android:paddingHorizontal="15dp" 54 android:paddingHorizontal="15dp"
39 android:paddingVertical="11dp" 55 android:paddingVertical="11dp"
40 android:layout_width="match_parent" 56 android:layout_width="match_parent"
41 android:layout_height="wrap_content"> 57 android:layout_height="wrap_content">
42 <androidx.appcompat.widget.AppCompatTextView 58 <androidx.appcompat.widget.AppCompatTextView
43 android:id="@+id/ftSubject" 59 android:id="@+id/ftSubject"
44 android:text="学科" 60 android:text="学科"
45 style="@style/tv_StudentHomeworkFilter"/> 61 style="@style/tv_StudentHomeworkFilter"/>
46 <Space style="@style/empty_space"/> 62 <Space style="@style/empty_space"/>
47 <androidx.appcompat.widget.AppCompatTextView 63 <androidx.appcompat.widget.AppCompatTextView
48 android:id="@+id/ftGrade" 64 android:id="@+id/ftGrade"
49 android:text="年级" 65 android:text="年级"
50 style="@style/tv_StudentHomeworkFilter"/> 66 style="@style/tv_StudentHomeworkFilter"/>
51 <Space style="@style/empty_space"/> 67 <Space style="@style/empty_space"/>
52 <androidx.appcompat.widget.AppCompatTextView 68 <androidx.appcompat.widget.AppCompatTextView
53 android:id="@+id/ftTerm" 69 android:id="@+id/ftTerm"
54 android:text="学期" 70 android:text="学期"
55 style="@style/tv_StudentHomeworkFilter"/> 71 style="@style/tv_StudentHomeworkFilter"/>
56 <Space style="@style/empty_space"/> 72 <Space style="@style/empty_space"/>
57 <androidx.appcompat.widget.AppCompatTextView 73 <androidx.appcompat.widget.AppCompatTextView
58 android:id="@+id/ftFeedback" 74 android:id="@+id/ftFeedback"
59 android:text="反馈状态" 75 android:text="反馈状态"
60 style="@style/tv_StudentHomeworkFilter"/> 76 style="@style/tv_StudentHomeworkFilter"/>
61 </LinearLayout> 77 </LinearLayout>
62 <androidx.legacy.widget.Space 78 <androidx.legacy.widget.Space
63 android:id="@+id/anchorView" 79 android:id="@+id/anchorView"
64 android:layout_width="0dp" 80 android:layout_width="0dp"
65 android:layout_height="0dp"/> 81 android:layout_height="0dp"/>
66 82
83 <FrameLayout
84 android:id="@+id/weekBar"
85 android:visibility="gone"
86 android:layout_width="match_parent"
87 android:layout_height="wrap_content">
88 <TextView
89 android:id="@+id/btnGeneralHuyou"
90 android:visibility="gone"
91 tools:visibility="visible"
92 android:text="生成本周作业总结"
93 android:textSize="13sp"
94 android:textColor="#1C90F3"
95 android:gravity="center"
96 android:textStyle="bold"
97 android:background="@drawable/btn_general_huyou"
98 android:layout_marginTop="16dp"
99 android:layout_marginHorizontal="30dp"
100 android:layout_width="match_parent"
101 android:layout_height="35dp"
102 tools:ignore="HardcodedText" />
103 </FrameLayout>
104
105 <FrameLayout
106 android:id="@+id/stageBar"
107 android:visibility="gone"
108 android:layout_width="match_parent"
109 android:layout_height="wrap_content">
110 <TextView
111 android:id="@+id/btnStageHuyou"
112 android:text="生成阶段性作业总结"
113 android:textSize="13sp"
114 android:textColor="#1C90F3"
115 android:gravity="center"
116 android:textStyle="bold"
117 android:background="@drawable/btn_general_huyou"
118 android:layout_marginTop="16dp"
119 android:layout_marginHorizontal="30dp"
120 android:layout_width="match_parent"
121 android:layout_height="35dp"
122 tools:ignore="HardcodedText" />
123 </FrameLayout>
124
67 <androidx.recyclerview.widget.RecyclerView 125 <androidx.recyclerview.widget.RecyclerView
68 android:id="@+id/recyclerView" 126 android:id="@+id/recyclerView"
69 android:background="#F8F8F8" 127 android:background="#F8F8F8"
70 android:orientation="vertical" 128 android:orientation="vertical"
71 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" 129 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
72 android:layout_width="match_parent" 130 android:layout_width="match_parent"
73 android:layout_height="match_parent"/> 131 android:layout_height="match_parent"/>
74 </LinearLayout> 132 </LinearLayout>
app/src/main/res/layout/dialog_stage_huyou.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <FrameLayout
3 xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent"
6 android:layout_height="match_parent"
7 tools:ignore="UselessParent,HardcodedText,ContentDescription,SmallSp">
8
9 <LinearLayout
10 android:scaleX="0.72"
11 android:scaleY="0.72"
12 android:orientation="vertical"
13 android:paddingBottom="16dp"
14 android:background="@drawable/shape_radius_10"
15 android:backgroundTint="@color/white"
16 android:layout_gravity="center"
17 android:layout_width="416dp"
18 android:layout_height="wrap_content">
19 <FrameLayout
20 android:paddingVertical="16dp"
21 android:layout_width="match_parent"
22 android:layout_height="wrap_content">
23 <TextView
24 android:id="@+id/tvTitle"
25 android:text="设置阶段性总结"
26 android:textSize="20sp"
27 android:textColor="#333"
28 android:textStyle="bold"
29 android:layout_gravity="center"
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"/>
32 <ImageView
33 android:id="@+id/btnClose"
34 android:src="@drawable/svg_close_24"
35 android:padding="8dp"
36 android:layout_marginEnd="8dp"
37 android:layout_gravity="end|center_vertical"
38 android:layout_width="32dp"
39 android:layout_height="32dp" />
40 </FrameLayout>
41
42 <TextView
43 android:text="选择时间:"
44 android:textSize="18sp"
45 android:textColor="#333"
46 android:textStyle="bold"
47 android:layout_marginHorizontal="16dp"
48 android:layout_marginTop="2dp"
49 android:layout_width="wrap_content"
50 android:layout_height="wrap_content"/>
51
52 <LinearLayout
53 android:orientation="horizontal"
54 android:layout_marginHorizontal="16dp"
55 android:layout_marginTop="12dp"
56 android:layout_width="match_parent"
57 android:layout_height="wrap_content">
58 <TextView
59 android:id="@+id/tvStart"
60 android:hint="开始时间"
61 android:textSize="18sp"
62 android:textColor="#333"
63 android:textColorHint="#999"
64 android:gravity="center_vertical"
65 android:paddingHorizontal="6dp"
66 android:background="@drawable/bg_huyou_time_select"
67 android:layout_weight="1"
68 android:layout_width="0dp"
69 android:layout_height="36dp"/>
70 <TextView
71 android:text="至"
72 android:textSize="18sp"
73 android:textColor="#333"
74 android:layout_marginHorizontal="8dp"
75 android:layout_width="wrap_content"
76 android:layout_height="wrap_content"/>
77 <TextView
78 android:id="@+id/tvEnd"
79 android:hint="截至时间"
80 android:textSize="18sp"
81 android:textColor="#333"
82 android:textColorHint="#999"
83 android:gravity="center_vertical"
84 android:paddingHorizontal="6dp"
85 android:background="@drawable/bg_huyou_time_select"
86 android:layout_weight="1"
87 android:layout_width="0dp"
88 android:layout_height="36dp"/>
89 </LinearLayout>
90
91 <TextView
92 android:text="选择科目:"
93 android:textSize="18sp"
94 android:textColor="#333"
95 android:textStyle="bold"
96 android:layout_marginHorizontal="16dp"
97 android:layout_marginTop="24dp"
98 android:layout_width="wrap_content"
99 android:layout_height="wrap_content"/>
100 <RadioGroup
101 android:id="@+id/rgSubject"
102 android:orientation="horizontal"
103 android:layout_marginHorizontal="16dp"
104 android:layout_marginTop="12dp"
105 android:layout_width="match_parent"
106 android:layout_height="wrap_content">
107 <RadioButton
108 android:text="数学"
109 android:button="@null"
110 android:textSize="14sp"
111 android:gravity="center"
112 android:textColor="@color/color_huyou_subject_select"
113 android:background="@drawable/btn_huyou_subject_select"
114 android:layout_width="64dp"
115 android:layout_height="32dp"/>
116 <Space style="@style/empty_space"/>
117 <RadioButton
118 android:text="语文"
119 android:button="@null"
120 android:textSize="14sp"
121 android:gravity="center"
122 android:textColor="@color/color_huyou_subject_select"
123 android:background="@drawable/btn_huyou_subject_select"
124 android:layout_width="64dp"
125 android:layout_height="32dp"/>
126 <Space style="@style/empty_space"/>
127 <RadioButton
128 android:text="英语"
129 android:button="@null"
130 android:textSize="14sp"
131 android:gravity="center"
132 android:textColor="@color/color_huyou_subject_select"
133 android:background="@drawable/btn_huyou_subject_select"
134 android:layout_width="64dp"
135 android:layout_height="32dp"/>
136 <Space style="@style/empty_space"/>
137 <RadioButton
138 android:text="物理"
139 android:button="@null"
140 android:textSize="14sp"
141 android:gravity="center"
142 android:textColor="@color/color_huyou_subject_select"
143 android:background="@drawable/btn_huyou_subject_select"
144 android:layout_width="64dp"
145 android:layout_height="32dp"/>
146 <Space style="@style/empty_space"/>
147 <RadioButton
148 android:text="化学"
149 android:button="@null"
150 android:textSize="14sp"
151 android:gravity="center"
152 android:textColor="@color/color_huyou_subject_select"
153 android:background="@drawable/btn_huyou_subject_select"
154 android:layout_width="64dp"
155 android:layout_height="32dp"/>
156 </RadioGroup>
157
158 <TextView
159 android:id="@+id/btnConfirm"
160 android:text="确认生成"
161 android:textSize="18sp"
162 android:textColor="@color/white"
163 android:gravity="center"
164 android:background="@drawable/shape_circle"
165 android:backgroundTint="#489AFA"
166 android:layout_gravity="center_horizontal"
167 android:layout_marginTop="24dp"
168 android:layout_width="120dp"
169 android:layout_height="40dp"/>
170
171 </LinearLayout>
172
173 </FrameLayout>
app/src/main/res/values/appearance.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <resources> 2 <resources>
3 3
4 <style name="tab_home_item"> 4 <style name="tab_home_item">
5 <item name="android:textSize">16sp</item> 5 <item name="android:textSize">16sp</item>
6 <item name="android:textStyle">bold</item> 6 <item name="android:textStyle">bold</item>
7 </style> 7 </style>
8 8
9 <style name="tab_homework">
10 <item name="android:textSize">13sp</item>
11 </style>
12
9 </resources> 13 </resources>
libs/common/src/main/java/com/prws/common/bean/homework/StDetail.java
File was created 1 package com.prws.common.bean.homework;
2
3 import com.google.gson.Gson;
4 import com.google.gson.GsonBuilder;
5 import com.google.gson.reflect.TypeToken;
6
7 import java.util.ArrayList;
8 import java.util.Date;
9 import java.util.List;
10
11 public class StDetail {
12
13 public String id;
14
15 public String stuId;
16 public Date startTime;
17 public Date endTime;
18 public String homeworkSubject;
19 public String scId;
20 public String grade;
21
22 public int total;
23 public int correct;
24
25 public float mondayCorrection;
26 public float tuesdayCorrection;
27 public float wednesdayCorrection;
28 public float thursdayCorrection;
29 public float fridayCorrection;
30
31 public String correction;
32 public transient List<Correction> correctionList;
33
34 public List<Point> points;
35
36 public int type;
37
38 public void formatCollection() {
39 correctionList = new ArrayList<>();
40 if (correction == null) {
41 return;
42 }
43 Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
44 try {
45 List<Correction> list = gson.fromJson(correction, new TypeToken<List<Correction>>(){}.getType());
46 for (Correction item: list) {
47 if (item != null && item.date != null) {
48 correctionList.add(item);
49 }
50 }
51 } catch (Exception e){
52 e.printStackTrace();
53 }
54 }
55
56 public static class Point {
57 public String pointId;
58 public String pointName;
59 public float beforeState;
60 public float afterState;
61 public float gap;
62 public float correctness;
63 }
64
65 public static class Correction {
66 public float correction;
67 public Date date;
68 }
69
70 }
71
libs/common/src/main/java/com/prws/common/net/NetWorks.java
1 package com.prws.common.net; 1 package com.prws.common.net;
2 2
3 3
4 import com.google.gson.Gson; 4 import com.google.gson.Gson;
5 import com.google.gson.JsonObject; 5 import com.google.gson.JsonObject;
6 import com.prws.common.BuildConfig; 6 import com.prws.common.BuildConfig;
7 import com.prws.common.bean.CutPicBean; 7 import com.prws.common.bean.CutPicBean;
8 import com.prws.common.bean.GradeAndSubject; 8 import com.prws.common.bean.GradeAndSubject;
9 import com.prws.common.bean.PageInfo; 9 import com.prws.common.bean.PageInfo;
10 import com.prws.common.bean.ResponseResult; 10 import com.prws.common.bean.ResponseResult;
11 import com.prws.common.bean.ScheduleBean; 11 import com.prws.common.bean.ScheduleBean;
12 import com.prws.common.bean.Student; 12 import com.prws.common.bean.Student;
13 import com.prws.common.bean.Teacher; 13 import com.prws.common.bean.Teacher;
14 import com.prws.common.bean.TopicBean; 14 import com.prws.common.bean.TopicBean;
15 import com.prws.common.bean.UpdateBean; 15 import com.prws.common.bean.UpdateBean;
16 import com.prws.common.bean.baidu.BaiduInput; 16 import com.prws.common.bean.baidu.BaiduInput;
17 import com.prws.common.bean.homework.HomeWork; 17 import com.prws.common.bean.homework.HomeWork;
18 import com.prws.common.bean.homework.HomeworkDetail; 18 import com.prws.common.bean.homework.HomeworkDetail;
19 import com.prws.common.bean.homework.HomeworkList; 19 import com.prws.common.bean.homework.HomeworkList;
20 import com.prws.common.bean.homework.StDetail;
20 import com.prws.common.utils.BitmapUtils; 21 import com.prws.common.utils.BitmapUtils;
21 import com.prws.common.utils.SharedPreferencesUtil; 22 import com.prws.common.utils.SharedPreferencesUtil;
22 23
23 import java.io.File; 24 import java.io.File;
24 import java.util.HashMap; 25 import java.util.HashMap;
25 import java.util.List; 26 import java.util.List;
26 import java.util.Map; 27 import java.util.Map;
27 28
28 import io.reactivex.Observable; 29 import io.reactivex.Observable;
29 import io.reactivex.Observer; 30 import io.reactivex.Observer;
30 import io.reactivex.Single; 31 import io.reactivex.Single;
31 import io.reactivex.android.schedulers.AndroidSchedulers; 32 import io.reactivex.android.schedulers.AndroidSchedulers;
32 import io.reactivex.schedulers.Schedulers; 33 import io.reactivex.schedulers.Schedulers;
33 import okhttp3.MediaType; 34 import okhttp3.MediaType;
34 import okhttp3.MultipartBody; 35 import okhttp3.MultipartBody;
35 import okhttp3.RequestBody; 36 import okhttp3.RequestBody;
36 import okhttp3.ResponseBody; 37 import okhttp3.ResponseBody;
37 import retrofit2.Call; 38 import retrofit2.Call;
38 import retrofit2.Callback; 39 import retrofit2.Callback;
39 import retrofit2.http.Body; 40 import retrofit2.http.Body;
40 import retrofit2.http.GET; 41 import retrofit2.http.GET;
41 import retrofit2.http.Header; 42 import retrofit2.http.Header;
42 import retrofit2.http.Headers; 43 import retrofit2.http.Headers;
43 import retrofit2.http.Multipart; 44 import retrofit2.http.Multipart;
44 import retrofit2.http.POST; 45 import retrofit2.http.POST;
45 import retrofit2.http.PUT; 46 import retrofit2.http.PUT;
46 import retrofit2.http.Part; 47 import retrofit2.http.Part;
47 import retrofit2.http.PartMap; 48 import retrofit2.http.PartMap;
48 import retrofit2.http.Query; 49 import retrofit2.http.Query;
49 import retrofit2.http.Url; 50 import retrofit2.http.Url;
50 51
51 /** 52 /**
52 * 类名称:NetWorks 53 * 类名称:NetWorks
53 * 创建人: 54 * 创建人:
54 * <p> 55 * <p>
55 * 类描述:网络请求的操作类 56 * 类描述:网络请求的操作类
56 */ 57 */
57 public class NetWorks extends RetrofitUtils { 58 public class NetWorks extends RetrofitUtils {
58 //服务器路径 59 //服务器路径
59 public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); 60 public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class);
60 61
61 //设缓存有效期为1天 62 //设缓存有效期为1天
62 protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; 63 protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1;
63 //查询缓存的Cache-Control设置,使用缓存 64 //查询缓存的Cache-Control设置,使用缓存
64 protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; 65 protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC;
65 //查询网络的Cache-Control设置。不使用缓存 66 //查询网络的Cache-Control设置。不使用缓存
66 protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; 67 protected static final String CACHE_CONTROL_NETWORK = "max-age=0";
67 68
68 69
69 public interface NetService { 70 public interface NetService {
70 71
71 72
72 @GET("/api/v1/user/logout") 73 @GET("/api/v1/user/logout")
73 Observable<ResponseBody> logout(); 74 Observable<ResponseBody> logout();
74 75
75 @Multipart 76 @Multipart
76 @POST("/api/v1/user/upLoadAvatar") 77 @POST("/api/v1/user/upLoadAvatar")
77 Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); 78 Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis);
78 79
79 80
80 @Headers("Content-Type: application/json") 81 @Headers("Content-Type: application/json")
81 @POST("/api/v1/user/editUser") 82 @POST("/api/v1/user/editUser")
82 Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); 83 Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body);
83 84
84 @Headers("Content-Type: application/json") 85 @Headers("Content-Type: application/json")
85 @POST("/api/v1/user/changePassword") 86 @POST("/api/v1/user/changePassword")
86 Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); 87 Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body);
87 88
88 89
89 @GET("/api/v1/user/searchById") 90 @GET("/api/v1/user/searchById")
90 Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); 91 Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId);
91 92
92 93
93 @Headers("Content-Type: application/json") 94 @Headers("Content-Type: application/json")
94 @POST("/api/v1/auth/login") 95 @POST("/api/v1/auth/login")
95 Observable<ResponseBody> login(@Body RequestBody body); 96 Observable<ResponseBody> login(@Body RequestBody body);
96 97
97 @GET("/api/v1/resource/listGradeAndSubject") 98 @GET("/api/v1/resource/listGradeAndSubject")
98 Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); 99 Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token);
99 100
100 101
101 @GET("/api/v1/manager/generalQrCode") 102 @GET("/api/v1/manager/generalQrCode")
102 Observable<ResponseBody> generalQrCode(); 103 Observable<ResponseBody> generalQrCode();
103 104
104 @GET("/api/v1/parent/scanAndLogin?") 105 @GET("/api/v1/parent/scanAndLogin?")
105 Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); 106 Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId);
106 107
107 @GET("/api/v1/parent/getChildrenList") 108 @GET("/api/v1/parent/getChildrenList")
108 Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); 109 Observable<ResponseBody> getChildrenList(@Header("Authorization") String token);
109 110
110 111
111 @Headers("Content-Type: application/json") 112 @Headers("Content-Type: application/json")
112 @POST("/api/v1/parent/registerParent") 113 @POST("/api/v1/parent/registerParent")
113 Observable<ResponseBody> registerParent(@Body RequestBody body); 114 Observable<ResponseBody> registerParent(@Body RequestBody body);
114 115
115 116
116 @GET("/api/v1/parent/listChildren") 117 @GET("/api/v1/parent/listChildren")
117 Observable<ResponseBody> listChildren(@Header("Authorization") String token); 118 Observable<ResponseBody> listChildren(@Header("Authorization") String token);
118 119
119 120
120 @Headers("Content-Type: application/json") 121 @Headers("Content-Type: application/json")
121 @POST("/api/v1/parent/registerStudent") 122 @POST("/api/v1/parent/registerStudent")
122 Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); 123 Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body);
123 124
124 @Headers("Content-Type: application/json") 125 @Headers("Content-Type: application/json")
125 @POST("/api/v1/parent/bindTeacher") 126 @POST("/api/v1/parent/bindTeacher")
126 Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); 127 Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body);
127 128
128 @Multipart 129 @Multipart
129 @POST("/api/v1/user/upLoadAvatar") 130 @POST("/api/v1/user/upLoadAvatar")
130 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); 131 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file);
131 132
132 133
133 @Multipart 134 @Multipart
134 @POST("/api/v1/student/editStudentAvatar") 135 @POST("/api/v1/student/editStudentAvatar")
135 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); 136 Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map);
136 137
137 @Headers("Content-Type: application/json") 138 @Headers("Content-Type: application/json")
138 @POST("/api/v1/parent/editChild") 139 @POST("/api/v1/parent/editChild")
139 Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); 140 Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body);
140 141
141 @GET("/api/v1/student/getStudyPlanForThisWeek") 142 @GET("/api/v1/student/getStudyPlanForThisWeek")
142 Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); 143 Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId);
143 144
144 @GET("api/v1/parent/searchTeacher") 145 @GET("api/v1/parent/searchTeacher")
145 Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); 146 Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone);
146 147
147 @POST("api/v1/question/listErrorBook") 148 @POST("api/v1/question/listErrorBook")
148 Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); 149 Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body);
149 150
150 @POST 151 @POST
151 Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); 152 Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body);
152 153
153 @POST 154 @POST
154 Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); 155 Observable<CutPicBean> cut(@Url String url, @Body RequestBody body);
155 156
156 @POST 157 @POST
157 Observable<JsonObject> getBaiduToken(@Url String url); 158 Observable<JsonObject> getBaiduToken(@Url String url);
158 159
159 @Multipart 160 @Multipart
160 @POST("api/v1/pad/addErrorBook") 161 @POST("api/v1/pad/addErrorBook")
161 Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); 162 Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map);
162 163
163 @POST("api/v1/pad/deleteStuErrorBook") 164 @POST("api/v1/pad/deleteStuErrorBook")
164 Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); 165 Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map);
165 166
166 @PUT("api/v1/pad/updateStuErrorBookInfo") 167 @PUT("api/v1/pad/updateStuErrorBookInfo")
167 Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); 168 Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map);
168 169
169 @POST("api/v1/question/editErrorBook") 170 @POST("api/v1/question/editErrorBook")
170 Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); 171 Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map);
171 172
172 @GET("api/v1/resource/checkUpdate") 173 @GET("api/v1/resource/checkUpdate")
173 Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); 174 Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type);
174 175
175 @GET("api/v1/teacher/getStudentList") 176 @GET("api/v1/teacher/getStudentList")
176 Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); 177 Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id);
177 178
178 @GET("api/v1/teacher/getStudentList") 179 @GET("api/v1/teacher/getStudentList")
179 Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); 180 Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id);
180 181
181 @GET("api/v1/answer/listRecordForTeacher") 182 @GET("api/v1/answer/listRecordForTeacher")
182 Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); 183 Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id);
183 184
184 @GET("api/v1/homework/listHomeworkByStuId") 185 @GET("api/v1/homework/listHomeworkByStuId")
185 Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); 186 Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId);
186 187
187 @POST 188 @POST
188 Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); 189 Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body);
189 190
190 @Multipart 191 @Multipart
191 @POST("api/v1/homework/uploadHomework") 192 @POST("api/v1/homework/uploadHomework")
192 Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); 193 Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id);
193 194
194 @POST("api/v1/homework/uploadHomeworkAction") 195 @POST("api/v1/homework/uploadHomeworkAction")
195 Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); 196 Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map);
196 197
197 @GET("api/v1/homework/removeHomework") 198 @GET("api/v1/homework/removeHomework")
198 Single<ResponseResult<Boolean>> deleteHomework( 199 Single<ResponseResult<Boolean>> deleteHomework(
199 @Header("Authorization") String token, 200 @Header("Authorization") String token,
200 @Query("homeworkId") String homeworkId 201 @Query("homeworkId") String homeworkId
201 ); 202 );
202 203
203 @GET("api/v1/homework/listHomeworkById") 204 @GET("api/v1/homework/listHomeworkById")
204 Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); 205 Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId);
205 206
206 @POST("api/v1/homework/uploadHomeworkFeedback") 207 @POST("api/v1/homework/uploadHomeworkFeedback")
207 Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); 208 Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map);
208 209
209 @POST("api/v1/homework/editHomeworkInfo") 210 @POST("api/v1/homework/editHomeworkInfo")
210 Single<ResponseResult<Boolean>> editHomework( 211 Single<ResponseResult<Boolean>> editHomework(
211 @Header("Authorization") String token, 212 @Header("Authorization") String token,
212 @Body Object body 213 @Body Object body
213 ); 214 );
214 215
215 @GET("api/v1/homework/listHomeworkDetailByStuId") 216 @GET("api/v1/homework/listHomeworkDetailByStuId")
216 Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( 217 Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail(
217 @Header("Authorization") String token, 218 @Header("Authorization") String token,
218 @Query("stuId") String stuId, 219 @Query("stuId") String stuId,
219 @Query("homeworkId") String homeworkId, 220 @Query("homeworkId") String homeworkId,
220 // type 固定传true 221 // type 固定传true
221 @Query("type") boolean type 222 @Query("type") boolean type
222 ); 223 );
223 224
225 @GET("api/v1/homework/listHomeworkStatistics")
226 Single<ResponseResult<List<StDetail>>> getHuyouList(
227 @Header("Authorization") String token,
228 @Query("stuId") String stuId,
229 @Query("type") int type //0: 周报, 1:阶段总结
230 );
231
232 @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent")
233 Single<ResponseResult<StDetail>> getHuyouDetail(
234 @Header("Authorization") String token,
235 @Query("homeworkStatisticsId") String homeworkId
236 );
237
238 @GET("api/v1/demo/generalStatisticsHomework")
239 Single<ResponseResult<Object>> generalHuyou();
240
241 @POST("api/v1/homework/generalHomeworkStageStatistics")
242 Single<ResponseResult<Boolean>> generalStageHuyou(
243 @Header("Authorization") String token,
244 @Body Object body
245 );
246
247 @GET("api/v1/homework/removeHomeworkStatistics")
248 Single<ResponseResult<Boolean>> deleteHuyou(
249 @Header("Authorization") String token,
250 @Query("homeworkStatisticsId") String homeworkId
251 );
252
224 } 253 }
225 254
226 public static String getUserId() { 255 public static String getUserId() {
227 return (String) SharedPreferencesUtil.getData("userId", ""); 256 return (String) SharedPreferencesUtil.getData("userId", "");
228 } 257 }
229 258
230 public static String getHeader() { 259 public static String getHeader() {
231 return (String) SharedPreferencesUtil.getData("token", ""); 260 return (String) SharedPreferencesUtil.getData("token", "");
232 } 261 }
233 262
234 public static String getBaiduToken() { 263 public static String getBaiduToken() {
235 return (String) SharedPreferencesUtil.getData("baiduToken", ""); 264 return (String) SharedPreferencesUtil.getData("baiduToken", "");
236 } 265 }
237 266
238 public static Single<BaiduInput> inputImage(String filePath, String id) { 267 public static Single<BaiduInput> inputImage(String filePath, String id) {
239 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); 268 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
240 String base64 = BitmapUtils.fileToBase64(filePath); 269 String base64 = BitmapUtils.fileToBase64(filePath);
241 File file = new File(filePath); 270 File file = new File(filePath);
242 RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); 271 RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}");
243 return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) 272 return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString())
244 .flatMap(token -> { 273 .flatMap(token -> {
245 return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); 274 return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body);
246 }); 275 });
247 } 276 }
248 277
249 public static Single<ResponseResult> uploadImage(String path, String id) { 278 public static Single<ResponseResult> uploadImage(String path, String id) {
250 File file = new File(path); 279 File file = new File(path);
251 RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); 280 RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file);
252 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 281 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
253 return service_url.uploadImage(getHeader(), part, id); 282 return service_url.uploadImage(getHeader(), part, id);
254 } 283 }
255 284
256 285
257 public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { 286 public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) {
258 service_url.checkUpdate(code, packageName, 0).enqueue(callback); 287 service_url.checkUpdate(code, packageName, 0).enqueue(callback);
259 } 288 }
260 289
261 public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { 290 public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) {
262 File file = new File(path); 291 File file = new File(path);
263 RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); 292 RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file);
264 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 293 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
265 Map<String, Object> map = new HashMap<>(); 294 Map<String, Object> map = new HashMap<>();
266 map.put("condition", param); 295 map.put("condition", param);
267 setSubscribe(service_url.addError(part, map), observer); 296 setSubscribe(service_url.addError(part, map), observer);
268 } 297 }
269 298
270 299
271 public static void cut(String base64, Observer<CutPicBean> observer) { 300 public static void cut(String base64, Observer<CutPicBean> observer) {
272 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); 301 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
273 RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); 302 RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true");
274 setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); 303 setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer);
275 } 304 }
276 305
277 public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { 306 public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) {
278 setSubscribe(service_url.editError(getHeader(), map), observer); 307 setSubscribe(service_url.editError(getHeader(), map), observer);
279 } 308 }
280 309
281 public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { 310 public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) {
282 setSubscribe(service_url.updateError(getHeader(), map), observer); 311 setSubscribe(service_url.updateError(getHeader(), map), observer);
283 } 312 }
284 313
285 public static void deleteError(List<String> map, Observer<ResponseResult> observer) { 314 public static void deleteError(List<String> map, Observer<ResponseResult> observer) {
286 setSubscribe(service_url.deleteError(getHeader(), map), observer); 315 setSubscribe(service_url.deleteError(getHeader(), map), observer);
287 } 316 }
288 317
289 public static void getBaiduToken(Observer<JsonObject> observer) { 318 public static void getBaiduToken(Observer<JsonObject> observer) {
290 setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer); 319 setSubscribe(service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey + "&client_secret=" + BuildConfig.SecretKey), observer);
291 } 320 }
292 321
293 public static Single<JsonObject> getBaiduTokenOcr() { 322 public static Single<JsonObject> getBaiduTokenOcr() {
294 return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError(); 323 return service_url.getBaiduToken("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + BuildConfig.APIKey1 + "&client_secret=" + BuildConfig.SecretKey1).firstOrError();
295 } 324 }
296 325
297 public static void removeWriting(String base64, Observer<JsonObject> observer) { 326 public static void removeWriting(String base64, Observer<JsonObject> observer) {
298 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); 327 MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
299 RequestBody body = RequestBody.create(mediaType, "image=" + base64); 328 RequestBody body = RequestBody.create(mediaType, "image=" + base64);
300 setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); 329 setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer);
301 } 330 }
302 331
303 public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { 332 public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) {
304 setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); 333 setSubscribe(service_url.searchTeacher(getHeader(), phone), observer);
305 } 334 }
306 335
307 public static void logout(Observer<ResponseBody> observer) { 336 public static void logout(Observer<ResponseBody> observer) {
308 setSubscribe(service_url.logout(), observer); 337 setSubscribe(service_url.logout(), observer);
309 } 338 }
310 339
311 public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { 340 public static void editStudent(RequestBody body, Observer<ResponseResult> observable) {
312 setSubscribe(service_url.editStudent(getHeader(), body), observable); 341 setSubscribe(service_url.editStudent(getHeader(), body), observable);
313 } 342 }
314 343
315 public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { 344 public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) {
316 setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); 345 setSubscribe(service_url.getWeekPlan(getHeader(), id), observer);
317 } 346 }
318 347
319 public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { 348 public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) {
320 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); 349 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
321 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 350 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
322 Map<String, Object> map = new HashMap<>(); 351 Map<String, Object> map = new HashMap<>();
323 map.put("stuId", stuId); 352 map.put("stuId", stuId);
324 setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); 353 setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer);
325 } 354 }
326 355
327 public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { 356 public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) {
328 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); 357 RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
329 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); 358 MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
330 setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); 359 setSubscribe(service_url.uploadAvatar(getHeader(), part), observer);
331 } 360 }
332 361
333 public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { 362 public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) {
334 setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); 363 setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer);
335 } 364 }
336 365
337 366
338 public static void editUser(RequestBody body, Observer<ResponseBody> observer) { 367 public static void editUser(RequestBody body, Observer<ResponseBody> observer) {
339 setSubscribe(service_url.editUser(getHeader(), body), observer); 368 setSubscribe(service_url.editUser(getHeader(), body), observer);
340 } 369 }
341 370
342 public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { 371 public static void changePassword(RequestBody body, Observer<ResponseBody> observer) {
343 setSubscribe(service_url.changePassword(getHeader(), body), observer); 372 setSubscribe(service_url.changePassword(getHeader(), body), observer);
344 } 373 }
345 374
346 375
347 public static void searchById(String userId, Observer<ResponseBody> observer) { 376 public static void searchById(String userId, Observer<ResponseBody> observer) {
348 setSubscribe(service_url.searchById(getHeader(), userId), observer); 377 setSubscribe(service_url.searchById(getHeader(), userId), observer);
349 } 378 }
350 379
351 380
352 public static void login(RequestBody body, Observer<ResponseBody> observer) { 381 public static void login(RequestBody body, Observer<ResponseBody> observer) {
353 setSubscribe(service_url.login(body), observer); 382 setSubscribe(service_url.login(body), observer);
354 } 383 }
355 384
356 public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { 385 public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) {
357 setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); 386 setSubscribe(service_url.listGradeAndSubject(getHeader()), observer);
358 } 387 }
359 388
360 389
361 public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { 390 public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) {
362 setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); 391 setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer);
363 } 392 }
364 393
365 public static void getChildrenList(Observer<ResponseBody> observer) { 394 public static void getChildrenList(Observer<ResponseBody> observer) {
366 setSubscribe(service_url.getChildrenList(getHeader()), observer); 395 setSubscribe(service_url.getChildrenList(getHeader()), observer);
367 } 396 }
368 397
369 398
370 public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { 399 public static void registerParent(RequestBody body, Observer<ResponseBody> observer) {
371 setSubscribe(service_url.registerParent(body), observer); 400 setSubscribe(service_url.registerParent(body), observer);
372 } 401 }
373 402
374 403
375 public static void listChildren(Observer<ResponseBody> observer) { 404 public static void listChildren(Observer<ResponseBody> observer) {
376 setSubscribe(service_url.listChildren(getHeader()), observer); 405 setSubscribe(service_url.listChildren(getHeader()), observer);
377 } 406 }
378 407
379 public static void listStudent(Observer<ResponseBody> observer) { 408 public static void listStudent(Observer<ResponseBody> observer) {
380 setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); 409 setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer);
381 } 410 }
382 411
383 public static Single<ResponseResult<List<Student>>> listStudent() { 412 public static Single<ResponseResult<List<Student>>> listStudent() {
384 return service_url.getStudentList2(getHeader(), getUserId()); 413 return service_url.getStudentList2(getHeader(), getUserId());
385 } 414 }
386 415
387 public static void listRecord(Observer<ResponseBody> observer) { 416 public static void listRecord(Observer<ResponseBody> observer) {
388 setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); 417 setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer);
389 } 418 }
390 419
391 420
392 public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { 421 public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) {
393 setSubscribe(service_url.registerStudent(getHeader(), body), observer); 422 setSubscribe(service_url.registerStudent(getHeader(), body), observer);
394 } 423 }
395 424
396 public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { 425 public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) {
397 setSubscribe(service_url.bindTeacher(getHeader(), body), observer); 426 setSubscribe(service_url.bindTeacher(getHeader(), body), observer);
398 } 427 }
399 428
400 public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { 429 public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) {
401 setSubscribe(service_url.getError(getHeader(), map), observer); 430 setSubscribe(service_url.getError(getHeader(), map), observer);
402 } 431 }
403 432
404 433
405 public static RequestBody getMapRequestBody(Map map) { 434 public static RequestBody getMapRequestBody(Map map) {
406 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); 435 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map));
407 } 436 }
408 437
409 438
410 public static RequestBody getArrayRequestBody(List list) { 439 public static RequestBody getArrayRequestBody(List list) {
411 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); 440 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list));
412 } 441 }
413 442
414 public static RequestBody getFileRequestBody(File file) { 443 public static RequestBody getFileRequestBody(File file) {
415 return RequestBody.create(MediaType.parse("application/octet-stream"), file); 444 return RequestBody.create(MediaType.parse("application/octet-stream"), file);
416 } 445 }
417 446
418 public static RequestBody getFileRequestBody(byte[] bytes) { 447 public static RequestBody getFileRequestBody(byte[] bytes) {
419 return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); 448 return RequestBody.create(MediaType.parse("multipart/form-data"), bytes);
420 } 449 }
421 450
422 public static RequestBody getObjectRequestBody(Object obj) { 451 public static RequestBody getObjectRequestBody(Object obj) {
423 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); 452 return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj));
424 } 453 }
425 454
426 public static RequestBody getStringRequestBody(String str) { 455 public static RequestBody getStringRequestBody(String str) {
427 return RequestBody.create(MediaType.parse("text/plain"), str); 456 return RequestBody.create(MediaType.parse("text/plain"), str);
428 } 457 }
429 458
430 459
431 /** 460 /**
432 * 插入观察者 461 * 插入观察者
433 * 462 *
434 * @param observable 463 * @param observable
435 * @param observer 464 * @param observer
436 * @param <T> 465 * @param <T>
437 */ 466 */
438 public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { 467 public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) {
439 observable.subscribeOn(Schedulers.io())//子线程访问网络 468 observable.subscribeOn(Schedulers.io())//子线程访问网络
440 .observeOn(AndroidSchedulers.mainThread())//回调到主线程 469 .observeOn(AndroidSchedulers.mainThread())//回调到主线程
441 .subscribe(observer); 470 .subscribe(observer);
442 } 471 }
443 472
444 } 473 }
445 474