Commit 07abc9da6376a50bd7c2bf6479a084c7768ba2ec
1 parent
b97677fa12
Exists in
master
发布反馈修改, 添加未做题
Showing
17 changed files
with
267 additions
and
126 deletions
Show diff stats
app/src/main/java/com/hjx/parent/HomeworkFeedbackActivity.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.View; | 6 | import android.view.View; |
7 | import android.widget.ImageView; | 7 | import android.widget.ImageView; |
8 | import android.widget.RadioButton; | 8 | import android.widget.RadioButton; |
9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
10 | 10 | ||
11 | import androidx.annotation.NonNull; | 11 | import androidx.annotation.NonNull; |
12 | import androidx.annotation.Nullable; | 12 | import androidx.annotation.Nullable; |
13 | 13 | ||
14 | import com.bumptech.glide.Glide; | 14 | import com.bumptech.glide.Glide; |
15 | import com.chad.library.adapter.base.BaseQuickAdapter; | 15 | import com.chad.library.adapter.base.BaseQuickAdapter; |
16 | import com.chad.library.adapter.base.BaseViewHolder; | 16 | import com.chad.library.adapter.base.BaseViewHolder; |
17 | import com.google.android.flexbox.FlexboxLayoutManager; | 17 | import com.google.android.flexbox.FlexboxLayoutManager; |
18 | import com.google.gson.Gson; | 18 | import com.google.gson.Gson; |
19 | import com.hjx.parent.databinding.ActivityHomeworkFeedbackBinding; | 19 | import com.hjx.parent.databinding.ActivityHomeworkFeedbackBinding; |
20 | import com.hjx.parent.rx.BaseRxActivity; | 20 | import com.hjx.parent.rx.BaseRxActivity; |
21 | import com.prws.common.bean.Student; | 21 | import com.prws.common.bean.Student; |
22 | import com.prws.common.bean.homework.Correction; | ||
23 | import com.prws.common.bean.homework.CorrectionPoint; | 22 | import com.prws.common.bean.homework.CorrectionPoint; |
24 | import com.prws.common.bean.homework.CorrectionSer; | 23 | import com.prws.common.bean.homework.CorrectionSer; |
25 | import com.prws.common.bean.homework.HomeWork; | 24 | import com.prws.common.bean.homework.HomeWork; |
26 | import com.prws.common.bean.homework.HomeworkList; | 25 | import com.prws.common.bean.homework.HomeworkList; |
27 | import com.prws.common.bean.homework.KeyValue; | 26 | import com.prws.common.bean.homework.KeyValue; |
28 | import com.prws.common.net.NetWorks; | 27 | import com.prws.common.net.NetWorks; |
29 | 28 | ||
30 | import java.text.DecimalFormat; | 29 | import java.text.DecimalFormat; |
31 | import java.text.SimpleDateFormat; | 30 | import java.text.SimpleDateFormat; |
32 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
33 | import java.util.HashMap; | 32 | import java.util.HashMap; |
34 | import java.util.HashSet; | 33 | import java.util.HashSet; |
35 | import java.util.List; | 34 | import java.util.List; |
36 | import java.util.Locale; | 35 | import java.util.Locale; |
37 | import java.util.Map; | 36 | import java.util.Map; |
38 | import java.util.Set; | 37 | import java.util.Set; |
39 | 38 | ||
40 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { | 39 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { |
41 | private Student student; | 40 | private Student student; |
42 | private HomeworkList mData; | 41 | private HomeworkList mData; |
43 | private ArrayList<HomeWork> mList; | 42 | private ArrayList<HomeWork> mList; |
44 | private List<Correction> corrections = new ArrayList<>(); | 43 | private List<CorrectionSer> corrections = new ArrayList<>(); |
45 | 44 | ||
46 | @SuppressWarnings("unchecked") | 45 | @SuppressWarnings("unchecked") |
47 | @Override | 46 | @Override |
48 | public void initView(Bundle savedInstanceState) { | 47 | public void initView(Bundle savedInstanceState) { |
49 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | 48 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); |
50 | student = (Student) getIntent().getSerializableExtra("student"); | 49 | student = (Student) getIntent().getSerializableExtra("student"); |
51 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); | 50 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); |
52 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | 51 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); |
53 | 52 | ||
54 | binding.tvStuName.setText(student.stuName); | 53 | binding.tvStuName.setText(student.stuName); |
55 | binding.tvGrade.setText(student.grade); | 54 | binding.tvGrade.setText(student.grade); |
56 | 55 | ||
56 | List<HomeWork> correctList = new ArrayList<>(); | ||
57 | List<HomeWork> errorList = new ArrayList<>(); | 57 | List<HomeWork> errorList = new ArrayList<>(); |
58 | int correctNo = 0; | 58 | List<HomeWork> blankList = new ArrayList<>(); |
59 | int correctNo = 0, blankNo = 0; | ||
59 | for (HomeWork homeWork: mList) { | 60 | for (HomeWork homeWork: mList) { |
60 | homeWork.state = 1; | 61 | homeWork.state = 1; |
61 | homeWork.index = mList.indexOf(homeWork); | 62 | homeWork.index = mList.indexOf(homeWork); |
62 | corrections.add(new Correction(homeWork.brief, homeWork.check ? 1 : 0)); | 63 | corrections.add(homeWork.toSer()); |
63 | if (!homeWork.check) correctNo ++; | 64 | if (homeWork.correction == 0) { |
64 | else errorList.add(homeWork); | 65 | correctList.add(homeWork); |
66 | correctNo ++; | ||
67 | } | ||
68 | else if (homeWork.correction == 1) { | ||
69 | correctList.add(homeWork); | ||
70 | errorList.add(homeWork); | ||
71 | } | ||
72 | else if (homeWork.correction == 2) { | ||
73 | blankList.add(homeWork); | ||
74 | blankNo ++; | ||
75 | } | ||
65 | } | 76 | } |
66 | binding.tvPercent.setText(new DecimalFormat("0%").format(1f * correctNo / mList.size())); | 77 | binding.viewBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); |
78 | binding.rvBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); | ||
79 | |||
80 | float rate = 1f * correctNo / Math.max(mList.size() - blankNo, 1); | ||
81 | binding.tvPercent.setText(new DecimalFormat("0%").format(rate)); | ||
67 | 82 | ||
68 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); | 83 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); |
69 | NumberAdapter numberAdapter = new NumberAdapter(mList); | 84 | binding.rvBlank.setLayoutManager(new FlexboxLayoutManager(this)); |
85 | NumberAdapter numberAdapter = new NumberAdapter(correctList); | ||
86 | NumberAdapter blankAdapter = new NumberAdapter(blankList); | ||
70 | binding.rvCorrect.setAdapter(numberAdapter); | 87 | binding.rvCorrect.setAdapter(numberAdapter); |
88 | binding.rvBlank.setAdapter(blankAdapter); | ||
89 | |||
71 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); | 90 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); |
72 | binding.rvError.setAdapter(new EvalAdapter(errorList)); | 91 | binding.rvError.setAdapter(new EvalAdapter(errorList)); |
73 | if (errorList.isEmpty()) { | 92 | if (errorList.isEmpty()) { |
74 | binding.flEval.setVisibility(View.GONE); | 93 | binding.flEval.setVisibility(View.GONE); |
75 | } | 94 | } |
76 | 95 | ||
77 | binding.btnDetail.setOnClickListener(v -> { | 96 | binding.btnDetail.setOnClickListener(v -> { |
78 | viewTopicDetail(0); | 97 | viewTopicDetail(0); |
79 | }); | 98 | }); |
99 | binding.btnDetail2.setOnClickListener(v -> { | ||
100 | viewTopicDetail(0); | ||
101 | }); | ||
80 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | 102 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { |
81 | viewTopicDetail(i); | 103 | viewTopicDetail(i); |
82 | }); | 104 | }); |
105 | blankAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | ||
106 | viewTopicDetail(i); | ||
107 | }); | ||
83 | binding.btnPublish.setOnClickListener(v -> submit()); | 108 | binding.btnPublish.setOnClickListener(v -> submit()); |
84 | } | 109 | } |
85 | 110 | ||
86 | private void viewTopicDetail(int position) { | 111 | private void viewTopicDetail(int position) { |
87 | Intent intent = new Intent(this, HomeworkTopicActivity.class); | 112 | Intent intent = new Intent(this, HomeworkTopicActivity.class); |
88 | intent.putExtra("list", mList); | 113 | intent.putExtra("list", mList); |
89 | intent.putExtra("position", position); | 114 | intent.putExtra("position", position); |
90 | startActivity(intent); | 115 | startActivity(intent); |
91 | } | 116 | } |
92 | 117 | ||
93 | @SuppressLint("CheckResult") | 118 | @SuppressLint("CheckResult") |
94 | private void submit() { | 119 | private void submit() { |
95 | Map<String, Object> body = new HashMap<>(); | 120 | Map<String, Object> body = new HashMap<>(); |
96 | body.put("homeworkId", mData.getId()); | 121 | body.put("homeworkId", mData.getId()); |
97 | body.put("comment", binding.etComment.getText().toString()); | 122 | body.put("comment", binding.etComment.getText().toString()); |
98 | body.put("stuId", student.stuId); | 123 | body.put("stuId", student.stuId); |
99 | body.put("points", countPoint()); | 124 | body.put("points", countPoint()); |
100 | body.put("correctionList", corrections); | 125 | body.put("correctionList", corrections); |
101 | body.put("extra", buildExtra()); | 126 | body.put("extra", buildExtra()); |
102 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) | 127 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) |
103 | .compose(transformSingle()) | 128 | .compose(transformSingle()) |
104 | .subscribe((response, th) -> { | 129 | .subscribe((response, th) -> { |
105 | if (th != null) th.printStackTrace(); | 130 | if (th != null) th.printStackTrace(); |
106 | if (response != null && response.getSuccess()) { | 131 | if (response != null && response.getSuccess()) { |
107 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); | 132 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); |
108 | 133 | ||
109 | Intent intent = new Intent(this, HomeworkShareActivity.class); | 134 | Intent intent = new Intent(this, HomeworkShareActivity.class); |
110 | intent.putExtra("student", student); | 135 | intent.putExtra("student", student); |
111 | intent.putExtra("id", mData.getId()); | 136 | intent.putExtra("id", mData.getId()); |
112 | intent.putExtra("grade", mData.getGrade()); | 137 | intent.putExtra("grade", mData.getGrade()); |
113 | intent.putExtra("subject", mData.getSubject()); | 138 | intent.putExtra("subject", mData.getSubject()); |
114 | String name = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(mData.uploadTime); | 139 | String name = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(mData.uploadTime); |
115 | intent.putExtra("name", name); | 140 | intent.putExtra("name", name); |
116 | startActivity(intent); | 141 | startActivity(intent); |
117 | 142 | ||
118 | setResult(RESULT_OK); | 143 | setResult(RESULT_OK); |
119 | finish(); | 144 | finish(); |
120 | } else { | 145 | } else { |
121 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); | 146 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); |
122 | } | 147 | } |
123 | }); | 148 | }); |
124 | } | 149 | } |
125 | 150 | ||
126 | private String buildExtra() { | 151 | private String buildExtra() { |
127 | if (mList == null || mList.isEmpty()) return null; | 152 | if (mList == null || mList.isEmpty()) return null; |
128 | List<CorrectionSer> maps = new ArrayList<>(); | 153 | List<CorrectionSer> maps = new ArrayList<>(); |
129 | for (HomeWork item: mList) { | 154 | for (HomeWork item: mList) { |
130 | maps.add(item.toSer()); | 155 | maps.add(item.toSer()); |
131 | } | 156 | } |
132 | Gson gson = new Gson(); | 157 | Gson gson = new Gson(); |
133 | return gson.toJson(maps); | 158 | return gson.toJson(maps); |
134 | } | 159 | } |
135 | 160 | ||
136 | @SuppressLint("CheckResult") | 161 | @SuppressLint("CheckResult") |
137 | private List<CorrectionPoint> countPoint() { | 162 | private List<CorrectionPoint> countPoint() { |
138 | Set<KeyValue> set = new HashSet<>(); | 163 | Set<KeyValue> set = new HashSet<>(); |
139 | Map<String, Integer> totalTimes = new HashMap<>(); | 164 | Map<String, Integer> totalTimes = new HashMap<>(); |
140 | Map<String, Integer> correctTimes = new HashMap<>(); | 165 | Map<String, Integer> correctTimes = new HashMap<>(); |
141 | Map<String, Integer> underTimes = new HashMap<>(); | 166 | Map<String, Integer> underTimes = new HashMap<>(); |
142 | Map<String, Integer> baseTimes = new HashMap<>(); | 167 | Map<String, Integer> baseTimes = new HashMap<>(); |
143 | Map<String, Integer> normalTimes = new HashMap<>(); | 168 | Map<String, Integer> normalTimes = new HashMap<>(); |
144 | Gson gson = new Gson(); | 169 | Gson gson = new Gson(); |
145 | for (HomeWork homeWork: mList) { | 170 | for (HomeWork homeWork: mList) { |
146 | homeWork.formatPoints(gson); | 171 | homeWork.formatPoints(gson); |
147 | 172 | ||
148 | set.addAll(homeWork.pointsObj); | 173 | set.addAll(homeWork.pointsObj); |
149 | for (KeyValue keyValue: homeWork.pointsObj) { | 174 | for (KeyValue keyValue: homeWork.pointsObj) { |
150 | String key = keyValue.Key; | 175 | String key = keyValue.Key; |
151 | if (totalTimes.containsKey(key)) { | 176 | if (totalTimes.containsKey(key)) { |
152 | totalTimes.put(key, totalTimes.get(key) + 1); | 177 | totalTimes.put(key, totalTimes.get(key) + 1); |
153 | } else { | 178 | } else { |
154 | totalTimes.put(key, 1); | 179 | totalTimes.put(key, 1); |
155 | } | 180 | } |
156 | if (!homeWork.check) { | 181 | if (homeWork.correction == 0) { |
157 | if (correctTimes.containsKey(key)) { | 182 | if (correctTimes.containsKey(key)) { |
158 | correctTimes.put(key, correctTimes.get(key) + 1); | 183 | correctTimes.put(key, correctTimes.get(key) + 1); |
159 | } else { | 184 | } else { |
160 | correctTimes.put(key, 1); | 185 | correctTimes.put(key, 1); |
161 | } | 186 | } |
162 | } else if (homeWork.state == 1) { | 187 | } else if (homeWork.correction == 1) { |
163 | if (underTimes.containsKey(key)) { | 188 | if (homeWork.state == 1) { |
164 | underTimes.put(key, underTimes.get(key) + 1); | 189 | if (underTimes.containsKey(key)) { |
165 | } else { | 190 | underTimes.put(key, underTimes.get(key) + 1); |
166 | underTimes.put(key, 1); | 191 | } else { |
167 | } | 192 | underTimes.put(key, 1); |
168 | } else if (homeWork.state == 2) { | 193 | } |
169 | if (baseTimes.containsKey(key)) { | 194 | } else if (homeWork.state == 2) { |
170 | baseTimes.put(key, baseTimes.get(key) + 1); | 195 | if (baseTimes.containsKey(key)) { |
171 | } else { | 196 | baseTimes.put(key, baseTimes.get(key) + 1); |
172 | baseTimes.put(key, 1); | 197 | } else { |
173 | } | 198 | baseTimes.put(key, 1); |
174 | } else if (homeWork.state == 3) { | 199 | } |
175 | if (normalTimes.containsKey(key)) { | 200 | } else if (homeWork.state == 3) { |
176 | normalTimes.put(key, normalTimes.get(key) + 1); | 201 | if (normalTimes.containsKey(key)) { |
177 | } else { | 202 | normalTimes.put(key, normalTimes.get(key) + 1); |
178 | normalTimes.put(key, 1); | 203 | } else { |
204 | normalTimes.put(key, 1); | ||
205 | } | ||
179 | } | 206 | } |
180 | } | 207 | } |
181 | } | 208 | } |
182 | } | 209 | } |
183 | List<CorrectionPoint> points = new ArrayList<>(); | 210 | List<CorrectionPoint> points = new ArrayList<>(); |
184 | for (KeyValue obj: set) { | 211 | for (KeyValue obj: set) { |
185 | CorrectionPoint point = new CorrectionPoint(); | 212 | CorrectionPoint point = new CorrectionPoint(); |
186 | point.pointId = obj.Key; | 213 | point.pointId = obj.Key; |
187 | point.pointName = obj.Value; | 214 | point.pointName = obj.Value; |
188 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); | 215 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); |
189 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); | 216 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); |
190 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); | 217 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); |
191 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); | 218 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); |
192 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); | 219 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); |
193 | 220 | ||
194 | points.add(point); | 221 | points.add(point); |
195 | } | 222 | } |
196 | 223 | ||
197 | return points; | 224 | return points; |
198 | } | 225 | } |
199 | 226 | ||
200 | private int ifNull(Integer src, int defaultVal) { | 227 | private int ifNull(Integer src, int defaultVal) { |
201 | if (src == null) return defaultVal; | 228 | if (src == null) return defaultVal; |
202 | else return src; | 229 | else return src; |
203 | } | 230 | } |
204 | 231 | ||
205 | 232 | ||
206 | @Override | 233 | @Override |
207 | protected ActivityHomeworkFeedbackBinding getViewBinding() { | 234 | protected ActivityHomeworkFeedbackBinding getViewBinding() { |
208 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); | 235 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); |
209 | } | 236 | } |
210 | 237 | ||
211 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 238 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
212 | 239 | ||
213 | public NumberAdapter(List<HomeWork> list) { | 240 | public NumberAdapter(List<HomeWork> list) { |
214 | super(R.layout.item_feedback_num, list); | 241 | super(R.layout.item_feedback_num, list); |
215 | } | 242 | } |
216 | 243 | ||
217 | @Override | 244 | @Override |
218 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 245 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
219 | int position = getData().indexOf(homeWork); | 246 | int position = getData().indexOf(homeWork); |
220 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); | 247 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); |
221 | if (homeWork.check) { | 248 | if (homeWork.correction == 1) { |
222 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); | 249 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); |
223 | } else { | 250 | } else if (homeWork.correction == 0){ |
224 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); | 251 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); |
252 | } else { | ||
253 | holder.setImageDrawable(R.id.ivType, null); | ||
225 | } | 254 | } |
226 | } | 255 | } |
227 | } | 256 | } |
228 | 257 | ||
229 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 258 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
230 | 259 | ||
231 | public EvalAdapter(@Nullable List<HomeWork> data) { | 260 | public EvalAdapter(@Nullable List<HomeWork> data) { |
232 | super(R.layout.item_homework_eval, data); | 261 | super(R.layout.item_homework_eval, data); |
233 | } | 262 | } |
234 | 263 | ||
235 | @Override | 264 | @Override |
236 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 265 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
237 | holder.itemView.setClipToOutline(true); | 266 | holder.itemView.setClipToOutline(true); |
238 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); | 267 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); |
239 | ImageView iv = holder.getView(R.id.ivTopic); | 268 | ImageView iv = holder.getView(R.id.ivTopic); |
240 | Glide.with(mContext).load(homeWork.url).into(iv); | 269 | Glide.with(mContext).load(homeWork.url).into(iv); |
241 | 270 | ||
242 | RadioButton chk1 = holder.getView(R.id.chk1); | 271 | RadioButton chk1 = holder.getView(R.id.chk1); |
243 | RadioButton chk2 = holder.getView(R.id.chk2); | 272 | RadioButton chk2 = holder.getView(R.id.chk2); |
244 | RadioButton chk3 = holder.getView(R.id.chk3); | 273 | RadioButton chk3 = holder.getView(R.id.chk3); |
245 | chk1.setOnCheckedChangeListener((v, b) -> { | 274 | chk1.setOnCheckedChangeListener((v, b) -> { |
246 | if (b) { | 275 | if (b) { |
247 | homeWork.state = 1; | 276 | homeWork.state = 1; |
248 | } | 277 | } |
249 | }); | 278 | }); |
250 | chk2.setOnCheckedChangeListener((v, b) -> { | 279 | chk2.setOnCheckedChangeListener((v, b) -> { |
251 | if (b) { | 280 | if (b) { |
252 | homeWork.state = 2; | 281 | homeWork.state = 2; |
253 | } | 282 | } |
254 | }); | 283 | }); |
255 | chk3.setOnCheckedChangeListener((v, b) -> { | 284 | chk3.setOnCheckedChangeListener((v, b) -> { |
256 | if (b) { | 285 | if (b) { |
257 | homeWork.state = 3; | 286 | homeWork.state = 3; |
258 | } | 287 | } |
259 | }); | 288 | }); |
260 | chk1.setChecked(homeWork.state == 1); | 289 | chk1.setChecked(homeWork.state == 1); |
261 | chk2.setChecked(homeWork.state == 2); | 290 | chk2.setChecked(homeWork.state == 2); |
262 | chk3.setChecked(homeWork.state == 3); | 291 | chk3.setChecked(homeWork.state == 3); |
263 | } | 292 | } |
264 | } | 293 | } |
265 | } | 294 | } |
app/src/main/java/com/hjx/parent/HomeworkSelectActivity.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.content.res.ColorStateList; | 5 | import android.content.res.ColorStateList; |
6 | import android.graphics.drawable.Drawable; | ||
7 | import android.os.Bundle; | 6 | import android.os.Bundle; |
8 | import android.view.View; | 7 | import android.view.View; |
9 | import android.widget.CheckBox; | ||
10 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | import android.widget.RadioGroup; | ||
11 | import android.widget.TextView; | 10 | import android.widget.TextView; |
12 | 11 | ||
13 | import androidx.annotation.DrawableRes; | ||
14 | import androidx.annotation.NonNull; | 12 | import androidx.annotation.NonNull; |
15 | import androidx.annotation.Nullable; | 13 | import androidx.annotation.Nullable; |
16 | import androidx.core.content.res.ResourcesCompat; | ||
17 | import androidx.lifecycle.MutableLiveData; | ||
18 | 14 | ||
19 | import com.bumptech.glide.Glide; | 15 | import com.bumptech.glide.Glide; |
20 | import com.chad.library.adapter.base.BaseQuickAdapter; | 16 | import com.chad.library.adapter.base.BaseQuickAdapter; |
21 | import com.chad.library.adapter.base.BaseViewHolder; | 17 | import com.chad.library.adapter.base.BaseViewHolder; |
22 | import com.hjx.parent.databinding.ActivityHomeworkSelectBinding; | 18 | import com.hjx.parent.databinding.ActivityHomeworkSelectBinding; |
23 | import com.hjx.parent.function.Function1; | 19 | import com.hjx.parent.function.Function0; |
24 | import com.hjx.parent.rx.BaseRxActivity; | 20 | import com.hjx.parent.rx.BaseRxActivity; |
25 | import com.prws.common.bean.Student; | 21 | import com.prws.common.bean.Student; |
26 | import com.prws.common.bean.homework.HomeWork; | 22 | import com.prws.common.bean.homework.HomeWork; |
27 | import com.prws.common.bean.homework.HomeworkList; | 23 | import com.prws.common.bean.homework.HomeworkList; |
28 | 24 | ||
29 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
30 | 26 | ||
31 | public class HomeworkSelectActivity extends BaseRxActivity<ActivityHomeworkSelectBinding> { | 27 | public class HomeworkSelectActivity extends BaseRxActivity<ActivityHomeworkSelectBinding> { |
32 | 28 | ||
33 | private Student student; | 29 | private Student student; |
34 | private HomeworkList mData; | 30 | private HomeworkList mData; |
35 | private ArrayList<HomeWork> mList; | 31 | private ArrayList<HomeWork> mList; |
36 | private Adapter mAdapter = new Adapter(); | 32 | private Adapter mAdapter = new Adapter(); |
37 | 33 | ||
38 | MutableLiveData<Integer> selectNum = new MutableLiveData<>(0); | ||
39 | |||
40 | @SuppressLint("NotifyDataSetChanged") | 34 | @SuppressLint("NotifyDataSetChanged") |
41 | @SuppressWarnings("unchecked,ConstantConditions") | 35 | @SuppressWarnings("unchecked,ConstantConditions") |
42 | @Override | 36 | @Override |
43 | public void initView(Bundle savedInstanceState) { | 37 | public void initView(Bundle savedInstanceState) { |
44 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | 38 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); |
45 | student = (Student) getIntent().getSerializableExtra("student"); | 39 | student = (Student) getIntent().getSerializableExtra("student"); |
46 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); | 40 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); |
47 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | 41 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); |
42 | if (mList == null) mList = new ArrayList<>(); | ||
43 | for (HomeWork homeWork: mList) { | ||
44 | homeWork.correction = 0; | ||
45 | } | ||
48 | 46 | ||
49 | mAdapter.setNewData(mList); | 47 | mAdapter.setNewData(mList); |
50 | binding.recyclerView.setAdapter(mAdapter); | 48 | binding.recyclerView.setAdapter(mAdapter); |
51 | 49 | ||
52 | mAdapter.selectCall = i -> selectNum.setValue(selectNum.getValue() + i); | 50 | mAdapter.selectCall = () -> { |
53 | selectNum.observe(this, i -> { | 51 | int right = 0, error = 0, blank = 0; |
54 | binding.tvNumber.setText(String.valueOf(i)); | 52 | for (HomeWork homeWork: mList) { |
55 | if (i == 0) { | 53 | if (homeWork.correction == 0) right ++; |
56 | binding.btnConfirm.setText("作业全对"); | 54 | else if (homeWork.correction == 1) error ++; |
57 | binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF4ABC78)); | 55 | else if (homeWork.correction == 2) blank ++; |
58 | } else { | ||
59 | binding.btnConfirm.setText("下一步"); | ||
60 | binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF1C90F3)); | ||
61 | } | 56 | } |
62 | binding.chkAll.setChecked(i == mList.size() && i != 0); | 57 | binding.tvNumber.setText(String.valueOf(error)); |
63 | }); | 58 | binding.tvBlankNumber.setText(String.valueOf(blank)); |
64 | 59 | // if (right == mList.size()) { | |
65 | binding.chkAll.setOnClickListener(v -> { | 60 | // binding.btnConfirm.setText("作业全对"); |
66 | if (mList.size() == 0) return; | 61 | // binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF4ABC78)); |
67 | boolean b = binding.chkAll.isChecked(); | 62 | // } else { |
68 | for (HomeWork item: mList) { | 63 | // binding.btnConfirm.setText("下一步"); |
69 | item.check = b; | 64 | // binding.btnConfirm.setBackgroundTintList(ColorStateList.valueOf(0xFF1C90F3)); |
70 | } | 65 | // } |
71 | selectNum.setValue(b ? mList.size() : 0); | 66 | }; |
72 | mAdapter.notifyDataSetChanged(); | ||
73 | }); | ||
74 | 67 | ||
75 | binding.btnConfirm.setOnClickListener(v -> { | 68 | binding.btnConfirm.setOnClickListener(v -> { |
76 | Intent intent = new Intent(this, HomeworkFeedbackActivity.class); | 69 | Intent intent = new Intent(this, HomeworkFeedbackActivity.class); |
77 | intent.putExtra("data", mData); | 70 | intent.putExtra("data", mData); |
78 | intent.putExtra("list", mList); | 71 | intent.putExtra("list", mList); |
79 | intent.putExtra("student", student); | 72 | intent.putExtra("student", student); |
80 | startActivityForResult(intent, 0xA01); | 73 | startActivityForResult(intent, 0xA01); |
81 | }); | 74 | }); |
82 | } | 75 | } |
83 | 76 | ||
84 | @Override | 77 | @Override |
85 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 78 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
86 | super.onActivityResult(requestCode, resultCode, data); | 79 | super.onActivityResult(requestCode, resultCode, data); |
87 | if (requestCode == 0xA01 && resultCode == RESULT_OK) { | 80 | if (requestCode == 0xA01 && resultCode == RESULT_OK) { |
88 | setResult(RESULT_OK); | 81 | setResult(RESULT_OK); |
89 | finish(); | 82 | finish(); |
90 | } | 83 | } |
91 | } | 84 | } |
92 | 85 | ||
93 | @Override | 86 | @Override |
94 | protected ActivityHomeworkSelectBinding getViewBinding() { | 87 | protected ActivityHomeworkSelectBinding getViewBinding() { |
95 | return ActivityHomeworkSelectBinding.inflate(getLayoutInflater()); | 88 | return ActivityHomeworkSelectBinding.inflate(getLayoutInflater()); |
96 | } | 89 | } |
97 | 90 | ||
98 | 91 | ||
99 | static class Adapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 92 | static class Adapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
100 | public Adapter() { | 93 | public Adapter() { |
101 | super(R.layout.item_homework_detail); | 94 | super(R.layout.item_homework_detail); |
102 | } | 95 | } |
103 | public Function1<Integer> selectCall; | 96 | public Function0 selectCall; |
104 | 97 | ||
105 | @SuppressLint("SetTextI18n") | 98 | @SuppressLint("SetTextI18n") |
106 | @Override | 99 | @Override |
107 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 100 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
108 | TextView tvNumber = holder.getView(R.id.tvNumber); | 101 | TextView tvNumber = holder.getView(R.id.tvNumber); |
109 | ImageView imageView = holder.getView(R.id.ivTopic); | 102 | ImageView imageView = holder.getView(R.id.ivTopic); |
110 | int number = getData().indexOf(homeWork) + 1; | 103 | int number = getData().indexOf(homeWork) + 1; |
111 | tvNumber.setText("第" + number + "题"); | 104 | tvNumber.setText("第" + number + "题"); |
112 | Glide.with(mContext).load(homeWork.url).into(imageView); | 105 | Glide.with(mContext).load(homeWork.url).into(imageView); |
113 | 106 | ||
114 | if (homeWork.check) { | 107 | setBackground(homeWork, holder); |
115 | holder.itemView.setForeground(getDrawable(R.drawable.border_radius_10_red)); | 108 | RadioGroup radioGroup = holder.getView(R.id.radioGroup); |
116 | } else { | 109 | radioGroup.setVisibility(View.VISIBLE); |
117 | holder.itemView.setForeground(null); | 110 | |
118 | } | 111 | radioGroup.setOnCheckedChangeListener((group, checkedId) -> { |
119 | CheckBox checkBox = holder.getView(R.id.checkbox); | 112 | if (checkedId == R.id.rbRight) homeWork.correction = 0; |
120 | checkBox.setVisibility(View.VISIBLE); | 113 | else if (checkedId == R.id.rbError) homeWork.correction = 1; |
121 | checkBox.setOnCheckedChangeListener(null); | 114 | else if (checkedId == R.id.rbBlank) homeWork.correction = 2; |
122 | checkBox.setChecked(homeWork.check); | 115 | setBackground(homeWork, holder); |
123 | 116 | selectCall.invoke(); | |
124 | holder.itemView.setOnClickListener(v -> checkBox.performClick()); | ||
125 | checkBox.setOnCheckedChangeListener((v, b) -> { | ||
126 | homeWork.check = b; | ||
127 | if (selectCall != null) { | ||
128 | selectCall.invoke(b ? 1 : -1); | ||
129 | } | ||
130 | if (homeWork.check) { | ||
131 | holder.itemView.setForeground(getDrawable(R.drawable.border_radius_10_red)); | ||
132 | } else { | ||
133 | holder.itemView.setForeground(null); | ||
134 | } | ||
135 | }); | 117 | }); |
136 | } | 118 | } |
137 | 119 | ||
138 | private Drawable getDrawable(@DrawableRes int res) { | 120 | private void setBackground(HomeWork homeWork, BaseViewHolder helper) { |
app/src/main/java/com/hjx/parent/HomeworkTopicActivity.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.res.ColorStateList; | 4 | import android.content.res.ColorStateList; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.view.View; | 6 | import android.view.View; |
7 | import android.widget.TextView; | 7 | import android.widget.TextView; |
8 | 8 | ||
9 | import androidx.annotation.NonNull; | 9 | import androidx.annotation.NonNull; |
10 | import androidx.annotation.Nullable; | 10 | import androidx.annotation.Nullable; |
11 | 11 | ||
12 | import com.bumptech.glide.Glide; | 12 | import com.bumptech.glide.Glide; |
13 | import com.chad.library.adapter.base.BaseQuickAdapter; | 13 | import com.chad.library.adapter.base.BaseQuickAdapter; |
14 | import com.chad.library.adapter.base.BaseViewHolder; | 14 | import com.chad.library.adapter.base.BaseViewHolder; |
15 | import com.google.gson.Gson; | 15 | import com.google.gson.Gson; |
16 | import com.hjx.parent.databinding.ActivityTopicDetailBinding; | 16 | import com.hjx.parent.databinding.ActivityTopicDetailBinding; |
17 | import com.hjx.parent.dialog.PhotoViewDialog; | 17 | import com.hjx.parent.dialog.PhotoViewDialog; |
18 | import com.hjx.parent.rx.BaseRxActivity; | 18 | import com.hjx.parent.rx.BaseRxActivity; |
19 | import com.prws.common.bean.homework.HomeWork; | 19 | import com.prws.common.bean.homework.HomeWork; |
20 | import com.prws.common.bean.homework.KeyValue; | 20 | import com.prws.common.bean.homework.KeyValue; |
21 | 21 | ||
22 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
23 | import java.util.List; | 23 | import java.util.List; |
24 | 24 | ||
25 | public class HomeworkTopicActivity extends BaseRxActivity<ActivityTopicDetailBinding> { | 25 | public class HomeworkTopicActivity extends BaseRxActivity<ActivityTopicDetailBinding> { |
26 | private ArrayList<HomeWork> mList; | 26 | private ArrayList<HomeWork> mList; |
27 | private int position; | 27 | private int position; |
28 | 28 | ||
29 | @SuppressWarnings("unchecked") | 29 | @SuppressWarnings("unchecked") |
30 | @Override | 30 | @Override |
31 | public void initView(Bundle savedInstanceState) { | 31 | public void initView(Bundle savedInstanceState) { |
32 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | 32 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); |
33 | position = getIntent().getIntExtra("position", 0); | 33 | position = getIntent().getIntExtra("position", 0); |
34 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | 34 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); |
35 | NumberAdapter adapter = new NumberAdapter(mList); | 35 | NumberAdapter adapter = new NumberAdapter(mList); |
36 | binding.rvNumber.setAdapter(adapter); | 36 | binding.rvNumber.setAdapter(adapter); |
37 | 37 | ||
38 | binding.btnPre.setOnClickListener(v -> showTopic(position - 1)); | 38 | binding.btnPre.setOnClickListener(v -> showTopic(position - 1)); |
39 | binding.btnNext.setOnClickListener(v -> showTopic(position + 1)); | 39 | binding.btnNext.setOnClickListener(v -> showTopic(position + 1)); |
40 | adapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | 40 | adapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { |
41 | if (position == i) return; | 41 | if (position == i) return; |
42 | showTopic(i); | 42 | showTopic(i); |
43 | }); | 43 | }); |
44 | showTopic(position); | 44 | showTopic(position); |
45 | } | 45 | } |
46 | 46 | ||
47 | @SuppressLint("SetTextI18n") | 47 | @SuppressLint("SetTextI18n") |
48 | private void showTopic(int position) { | 48 | private void showTopic(int position) { |
49 | if (position < 0 || position >= mList.size()) return; | 49 | if (position < 0 || position >= mList.size()) return; |
50 | this.position = position; | 50 | this.position = position; |
51 | binding.btnPre.setEnabled(position > 0); | 51 | binding.btnPre.setEnabled(position > 0); |
52 | binding.btnNext.setEnabled(position < mList.size() - 1); | 52 | binding.btnNext.setEnabled(position < mList.size() - 1); |
53 | binding.tvTitle.setText((position + 1) + "/" + mList.size()); | 53 | binding.tvTitle.setText((position + 1) + "/" + mList.size()); |
54 | binding.tvNo.setText("题目" + (position + 1)); | 54 | binding.tvNo.setText("题目" + (position + 1)); |
55 | 55 | ||
56 | HomeWork homeWork = mList.get(position); | 56 | HomeWork homeWork = mList.get(position); |
57 | Glide.with(this).load(homeWork.url).into(binding.ivTopic); | 57 | Glide.with(this).load(homeWork.url).into(binding.ivTopic); |
58 | binding.ivTopic.setOnClickListener(v -> { | 58 | binding.ivTopic.setOnClickListener(v -> { |
59 | new PhotoViewDialog(this).show(homeWork.url); | 59 | new PhotoViewDialog(this).show(homeWork.url); |
60 | }); | 60 | }); |
61 | Glide.with(this).load(homeWork.analyseUrl).into(binding.ivAnalyse); | 61 | Glide.with(this).load(homeWork.analyseUrl).into(binding.ivAnalyse); |
62 | binding.ivAnalyse.setOnClickListener(v -> { | 62 | binding.ivAnalyse.setOnClickListener(v -> { |
63 | if (homeWork.analyseUrl == null || homeWork.analyseUrl.isEmpty()) return; | 63 | if (homeWork.analyseUrl == null || homeWork.analyseUrl.isEmpty()) return; |
64 | new PhotoViewDialog(this).show(homeWork.analyseUrl); | 64 | new PhotoViewDialog(this).show(homeWork.analyseUrl); |
65 | }); | 65 | }); |
66 | String answer = homeWork.answer == null ? "" : homeWork.answer | 66 | String answer = homeWork.answer == null ? "" : homeWork.answer |
67 | .replace("<br />", "\n") | 67 | .replace("<br />", "\n") |
68 | .replace("${", "") | 68 | .replace("${", "") |
69 | .replace("}$", ""); | 69 | .replace("}$", ""); |
70 | binding.tvAnswer.setText(answer); | 70 | binding.tvAnswer.setText(answer); |
71 | if (homeWork.pointsObj == null) homeWork.formatPoints(new Gson()); | 71 | if (homeWork.pointsObj == null) homeWork.formatPoints(new Gson()); |
72 | StringBuilder pointBuilder = new StringBuilder(); | 72 | StringBuilder pointBuilder = new StringBuilder(); |
73 | for (KeyValue point: homeWork.pointsObj) { | 73 | for (KeyValue point: homeWork.pointsObj) { |
74 | pointBuilder.append("\n").append(point.Value); | 74 | pointBuilder.append("\n").append(point.Value); |
75 | } | 75 | } |
76 | binding.tvPoint.setText(homeWork.pointsObj.size() == 0 ? "" : pointBuilder.substring(1)); | 76 | binding.tvPoint.setText(homeWork.pointsObj.size() == 0 ? "" : pointBuilder.substring(1)); |
77 | } | 77 | } |
78 | 78 | ||
79 | @Override | 79 | @Override |
80 | protected ActivityTopicDetailBinding getViewBinding() { | 80 | protected ActivityTopicDetailBinding getViewBinding() { |
81 | return ActivityTopicDetailBinding.inflate(getLayoutInflater()); | 81 | return ActivityTopicDetailBinding.inflate(getLayoutInflater()); |
82 | } | 82 | } |
83 | 83 | ||
84 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 84 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
85 | 85 | ||
86 | public NumberAdapter(@Nullable List<HomeWork> data) { | 86 | public NumberAdapter(@Nullable List<HomeWork> data) { |
87 | super(R.layout.item_topic_number, data); | 87 | super(R.layout.item_topic_number, data); |
88 | } | 88 | } |
89 | 89 | ||
90 | @Override | 90 | @Override |
91 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 91 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
92 | TextView textView = (TextView) holder.itemView; | 92 | TextView textView = (TextView) holder.itemView; |
93 | textView.setText(String.valueOf(getData().indexOf(homeWork) + 1)); | 93 | textView.setText(String.valueOf(getData().indexOf(homeWork) + 1)); |
94 | 94 | ||
95 | int color = homeWork.check ? 0xFFFF4133 : 0xFF4ABC78; | 95 | if (homeWork.correction == null || homeWork.correction == 2) { |
96 | textView.setBackgroundTintList(ColorStateList.valueOf(color)); | 96 | textView.setBackgroundTintList(ColorStateList.valueOf(0xFF999999)); |
97 | } else if (homeWork.correction == 0) { | ||
98 | textView.setBackgroundTintList(ColorStateList.valueOf(0xFF4ABC78)); | ||
99 | } else if (homeWork.correction == 1) { | ||
100 | textView.setBackgroundTintList(ColorStateList.valueOf(0xFFFF4133)); | ||
101 | } | ||
97 | } | 102 | } |
98 | } | 103 | } |
99 | } | 104 | } |
100 | 105 |
app/src/main/res/drawable/bg_feedback_blank.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="10dp"/> | ||
4 | <stroke android:color="#FDB900" android:width="2dp"/> | ||
5 | <solid android:color="@color/white"/> | ||
6 | </shape> |
app/src/main/res/drawable/bg_feedback_error.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="10dp"/> | ||
4 | <stroke android:color="#FF5138" android:width="2dp"/> | ||
5 | <solid android:color="@color/white"/> | ||
6 | </shape> |
app/src/main/res/drawable/bg_feedback_right.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <corners android:radius="10dp"/> | ||
4 | <stroke android:color="#00D39C" android:width="2dp"/> | ||
5 | <solid android:color="@color/white"/> | ||
6 | </shape> |
app/src/main/res/drawable/btn_feedback_blank.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:state_checked="false"> | ||
4 | <shape> | ||
5 | <corners android:radius="888dp"/> | ||
6 | <solid android:color="#C4DFFF"/> | ||
7 | </shape> | ||
8 | </item> | ||
9 | |||
10 | <item> | ||
11 | <shape> | ||
12 | <corners android:radius="888dp"/> | ||
13 | <solid android:color="#FDB900"/> | ||
14 | </shape> | ||
15 | </item> | ||
16 | </selector> |
app/src/main/res/drawable/btn_feedback_error.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:state_checked="false"> | ||
4 | <shape> | ||
5 | <corners android:radius="888dp"/> | ||
6 | <solid android:color="#C4DFFF"/> | ||
7 | </shape> | ||
8 | </item> | ||
9 | |||
10 | <item> | ||
11 | <shape> | ||
12 | <corners android:radius="888dp"/> | ||
13 | <solid android:color="#FF5138"/> | ||
14 | </shape> | ||
15 | </item> | ||
16 | </selector> |
app/src/main/res/drawable/btn_feedback_right.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:state_checked="false"> | ||
4 | <shape> | ||
5 | <corners android:radius="888dp"/> | ||
6 | <solid android:color="#C4DFFF"/> | ||
7 | </shape> | ||
8 | </item> | ||
9 | |||
10 | <item> | ||
11 | <shape> | ||
12 | <corners android:radius="888dp"/> | ||
13 | <solid android:color="#00D39C"/> | ||
14 | </shape> | ||
15 | </item> | ||
16 | </selector> |
app/src/main/res/drawable/shape_radius_10.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | 2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
3 | <corners android:radius="10dp"/> | 3 | <corners android:radius="10dp"/> |
4 | <solid android:color="@color/white"/> | ||
4 | </shape> | 5 | </shape> |
app/src/main/res/layout/activity_homework_feedback.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout | 2 | <LinearLayout |
3 | xmlns:android="http://schemas.android.com/apk/res/android" | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | 4 | xmlns:app="http://schemas.android.com/apk/res-auto" |
5 | xmlns:tools="http://schemas.android.com/tools" | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
7 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
8 | android:layout_height="match_parent" | 8 | android:layout_height="match_parent" |
9 | tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription"> | 9 | tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription"> |
10 | 10 | ||
11 | <androidx.appcompat.widget.Toolbar | 11 | <androidx.appcompat.widget.Toolbar |
12 | android:id="@+id/toolbar" | 12 | android:id="@+id/toolbar" |
13 | app:navigationIcon="@drawable/svg_back" | 13 | app:navigationIcon="@drawable/svg_back" |
14 | app:contentInsetStartWithNavigation="14dp" | 14 | app:contentInsetStartWithNavigation="14dp" |
15 | android:paddingStart="-8dp" | 15 | android:paddingStart="-8dp" |
16 | android:paddingEnd="-8dp" | 16 | android:paddingEnd="-8dp" |
17 | android:background="@color/white" | 17 | android:background="@color/white" |
18 | android:layout_width="match_parent" | 18 | android:layout_width="match_parent" |
19 | android:layout_height="40dp"> | 19 | android:layout_height="40dp"> |
20 | <TextView | 20 | <TextView |
21 | android:text="第二步:教师评语" | 21 | android:text="第二步:教师评语" |
22 | android:textSize="18sp" | 22 | android:textSize="18sp" |
23 | android:textColor="#333" | 23 | android:textColor="#333" |
24 | android:textStyle="bold" | 24 | android:textStyle="bold" |
25 | android:layout_gravity="center" | 25 | android:layout_gravity="center" |
26 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
27 | android:layout_height="wrap_content"/> | 27 | android:layout_height="wrap_content"/> |
28 | <TextView | 28 | <TextView |
29 | android:id="@+id/btnPublish" | 29 | android:id="@+id/btnPublish" |
30 | android:text="发布" | 30 | android:text="发布" |
31 | android:textSize="13sp" | 31 | android:textSize="13sp" |
32 | android:textColor="#1C90F3" | 32 | android:textColor="#1C90F3" |
33 | android:textStyle="bold" | 33 | android:textStyle="bold" |
34 | android:layout_gravity="end|center_vertical" | 34 | android:layout_gravity="end|center_vertical" |
35 | android:layout_marginEnd="24dp" | 35 | android:layout_marginEnd="24dp" |
36 | android:layout_width="wrap_content" | 36 | android:layout_width="wrap_content" |
37 | android:layout_height="wrap_content"/> | 37 | android:layout_height="wrap_content"/> |
38 | </androidx.appcompat.widget.Toolbar> | 38 | </androidx.appcompat.widget.Toolbar> |
39 | 39 | ||
40 | <androidx.core.widget.NestedScrollView | 40 | <androidx.core.widget.NestedScrollView |
41 | android:layout_width="match_parent" | 41 | android:layout_width="match_parent" |
42 | android:layout_height="match_parent"> | 42 | android:layout_height="match_parent"> |
43 | <LinearLayout | 43 | <LinearLayout |
44 | android:orientation="vertical" | 44 | android:orientation="vertical" |
45 | android:paddingHorizontal="15dp" | 45 | android:paddingHorizontal="15dp" |
46 | android:paddingBottom="20dp" | 46 | android:paddingBottom="20dp" |
47 | android:layout_width="match_parent" | 47 | android:layout_width="match_parent" |
48 | android:layout_height="wrap_content"> | 48 | android:layout_height="wrap_content"> |
49 | 49 | ||
50 | <LinearLayout | 50 | <LinearLayout |
51 | android:orientation="vertical" | 51 | android:orientation="vertical" |
52 | android:background="@drawable/shape_radius_10" | 52 | android:background="@drawable/shape_radius_10" |
53 | android:backgroundTint="@color/white" | 53 | android:backgroundTint="@color/white" |
54 | android:layout_marginTop="15dp" | 54 | android:layout_marginTop="15dp" |
55 | android:layout_width="match_parent" | 55 | android:layout_width="match_parent" |
56 | android:layout_height="wrap_content"> | 56 | android:layout_height="wrap_content"> |
57 | <androidx.appcompat.widget.AppCompatTextView | 57 | <androidx.appcompat.widget.AppCompatTextView |
58 | android:text="学生信息" | 58 | android:text="学生信息" |
59 | android:textSize="16sp" | 59 | android:textSize="16sp" |
60 | android:textColor="#333" | 60 | android:textColor="#333" |
61 | android:textStyle="bold" | 61 | android:textStyle="bold" |
62 | android:gravity="center_vertical" | 62 | android:gravity="center_vertical" |
63 | android:paddingHorizontal="15dp" | 63 | android:paddingHorizontal="15dp" |
64 | android:drawablePadding="5dp" | 64 | android:drawablePadding="5dp" |
65 | android:drawableStart="@drawable/svg_ic_stu_info" | 65 | android:drawableStart="@drawable/svg_ic_stu_info" |
66 | android:background="@drawable/shape_radius_top_10" | 66 | android:background="@drawable/shape_radius_top_10" |
67 | android:backgroundTint="#DAEBFE" | 67 | android:backgroundTint="#DAEBFE" |
68 | android:layout_width="match_parent" | 68 | android:layout_width="match_parent" |
69 | android:layout_height="40dp"/> | 69 | android:layout_height="40dp"/> |
70 | <LinearLayout | 70 | <LinearLayout |
71 | android:orientation="horizontal" | 71 | android:orientation="horizontal" |
72 | android:layout_marginHorizontal="15dp" | 72 | android:layout_marginHorizontal="15dp" |
73 | android:layout_marginVertical="18dp" | 73 | android:layout_marginVertical="18dp" |
74 | android:layout_width="match_parent" | 74 | android:layout_width="match_parent" |
75 | android:layout_height="wrap_content"> | 75 | android:layout_height="wrap_content"> |
76 | <TextView | 76 | <TextView |
77 | android:text="学生姓名:" | 77 | android:text="学生姓名:" |
78 | android:textSize="14sp" | 78 | android:textSize="14sp" |
79 | android:textColor="#333" | 79 | android:textColor="#333" |
80 | android:layout_width="wrap_content" | 80 | android:layout_width="wrap_content" |
81 | android:layout_height="wrap_content"/> | 81 | android:layout_height="wrap_content"/> |
82 | <TextView | 82 | <TextView |
83 | android:id="@+id/tvStuName" | 83 | android:id="@+id/tvStuName" |
84 | tools:text="杨小凯" | 84 | tools:text="杨小凯" |
85 | android:textSize="14sp" | 85 | android:textSize="14sp" |
86 | android:textColor="#333" | 86 | android:textColor="#333" |
87 | android:layout_width="wrap_content" | 87 | android:layout_width="wrap_content" |
88 | android:layout_height="wrap_content"/> | 88 | android:layout_height="wrap_content"/> |
89 | <Space style="@style/empty_space"/> | 89 | <Space style="@style/empty_space"/> |
90 | <TextView | 90 | <TextView |
91 | android:text="年级:" | 91 | android:text="年级:" |
92 | android:textSize="14sp" | 92 | android:textSize="14sp" |
93 | android:textColor="#333" | 93 | android:textColor="#333" |
94 | android:layout_width="wrap_content" | 94 | android:layout_width="wrap_content" |
95 | android:layout_height="wrap_content"/> | 95 | android:layout_height="wrap_content"/> |
96 | <TextView | 96 | <TextView |
97 | android:id="@+id/tvGrade" | 97 | android:id="@+id/tvGrade" |
98 | tools:text="六年级" | 98 | tools:text="六年级" |
99 | android:textSize="14sp" | 99 | android:textSize="14sp" |
100 | android:textColor="#333" | 100 | android:textColor="#333" |
101 | android:layout_width="96dp" | 101 | android:layout_width="96dp" |
102 | android:layout_height="wrap_content"/> | 102 | android:layout_height="wrap_content"/> |
103 | </LinearLayout> | 103 | </LinearLayout> |
104 | </LinearLayout> | 104 | </LinearLayout> |
105 | 105 | ||
106 | <LinearLayout | 106 | <LinearLayout |
107 | android:orientation="vertical" | 107 | android:orientation="vertical" |
108 | android:background="@drawable/shape_radius_10" | 108 | android:background="@drawable/shape_radius_10" |
109 | android:backgroundTint="@color/white" | 109 | android:backgroundTint="@color/white" |
110 | android:paddingBottom="15dp" | 110 | android:paddingBottom="15dp" |
111 | android:layout_marginTop="15dp" | 111 | android:layout_marginTop="15dp" |
112 | android:layout_width="match_parent" | 112 | android:layout_width="match_parent" |
113 | android:layout_height="wrap_content"> | 113 | android:layout_height="wrap_content"> |
114 | <androidx.appcompat.widget.AppCompatTextView | 114 | <androidx.appcompat.widget.AppCompatTextView |
115 | android:text="作业详情" | 115 | android:text="作业详情" |
116 | android:textSize="16sp" | 116 | android:textSize="16sp" |
117 | android:textColor="#333" | 117 | android:textColor="#333" |
118 | android:textStyle="bold" | 118 | android:textStyle="bold" |
119 | android:gravity="center_vertical" | 119 | android:gravity="center_vertical" |
120 | android:paddingHorizontal="15dp" | 120 | android:paddingHorizontal="15dp" |
121 | android:drawablePadding="5dp" | 121 | android:drawablePadding="5dp" |
122 | android:drawableStart="@drawable/svg_ic_correct" | 122 | android:drawableStart="@drawable/svg_ic_correct" |
123 | android:background="@drawable/shape_radius_top_10" | 123 | android:background="@drawable/shape_radius_top_10" |
124 | android:backgroundTint="#DAEBFE" | 124 | android:backgroundTint="#DAEBFE" |
125 | android:layout_width="match_parent" | 125 | android:layout_width="match_parent" |
126 | android:layout_height="40dp"/> | 126 | android:layout_height="40dp"/> |
127 | <LinearLayout | 127 | <LinearLayout |
128 | android:orientation="horizontal" | 128 | android:orientation="horizontal" |
129 | android:layout_marginHorizontal="15dp" | 129 | android:layout_marginHorizontal="15dp" |
130 | android:layout_marginTop="15dp" | 130 | android:layout_marginTop="15dp" |
131 | android:layout_width="match_parent" | 131 | android:layout_width="match_parent" |
132 | android:layout_height="wrap_content"> | 132 | android:layout_height="wrap_content"> |
133 | <TextView | 133 | <TextView |
134 | android:text="正确率:" | 134 | android:text="正确率:" |
135 | android:textSize="14sp" | 135 | android:textSize="14sp" |
136 | android:textColor="#333" | 136 | android:textColor="#333" |
137 | android:layout_width="wrap_content" | 137 | android:layout_width="wrap_content" |
138 | android:layout_height="wrap_content"/> | 138 | android:layout_height="wrap_content"/> |
139 | <TextView | 139 | <TextView |
140 | android:id="@+id/tvPercent" | 140 | android:id="@+id/tvPercent" |
141 | tools:text="60%" | 141 | tools:text="60%" |
142 | android:textSize="14sp" | 142 | android:textSize="14sp" |
143 | android:textColor="#333" | 143 | android:textColor="#333" |
144 | android:layout_width="wrap_content" | 144 | android:layout_width="wrap_content" |
145 | android:layout_height="wrap_content"/> | 145 | android:layout_height="wrap_content"/> |
146 | </LinearLayout> | 146 | </LinearLayout> |
147 | |||
147 | <LinearLayout | 148 | <LinearLayout |
148 | android:orientation="horizontal" | 149 | android:orientation="horizontal" |
149 | android:layout_marginHorizontal="15dp" | 150 | android:layout_marginHorizontal="15dp" |
150 | android:layout_marginTop="15dp" | 151 | android:layout_marginTop="15dp" |
151 | android:layout_width="match_parent" | 152 | android:layout_width="match_parent" |
152 | android:layout_height="wrap_content"> | 153 | android:layout_height="wrap_content"> |
153 | <TextView | 154 | <TextView |
154 | android:text="答题结果" | 155 | android:text="答题结果" |
155 | android:textSize="14sp" | 156 | android:textSize="14sp" |
156 | android:textColor="#333" | 157 | android:textColor="#333" |
157 | android:layout_width="wrap_content" | 158 | android:layout_width="wrap_content" |
158 | android:layout_height="wrap_content"/> | 159 | android:layout_height="wrap_content"/> |
159 | <TextView | 160 | <TextView |
160 | android:id="@+id/btnDetail" | 161 | android:id="@+id/btnDetail" |
161 | android:text="(点击查看题目详情)" | 162 | android:text="(点击查看题目详情)" |
162 | android:textSize="14sp" | 163 | android:textSize="14sp" |
163 | android:textColor="#1C90F3" | 164 | android:textColor="#1C90F3" |
164 | android:layout_width="wrap_content" | 165 | android:layout_width="wrap_content" |
165 | android:layout_height="wrap_content"/> | 166 | android:layout_height="wrap_content"/> |
166 | </LinearLayout> | 167 | </LinearLayout> |
167 | 168 | ||
168 | <androidx.recyclerview.widget.RecyclerView | 169 | <androidx.recyclerview.widget.RecyclerView |
169 | android:id="@+id/rvCorrect" | 170 | android:id="@+id/rvCorrect" |
170 | tools:listitem="@layout/item_feedback_num" | 171 | tools:listitem="@layout/item_feedback_num" |
171 | tools:itemCount="1" | 172 | tools:itemCount="1" |
172 | android:layout_marginTop="15dp" | 173 | android:layout_marginTop="15dp" |
173 | android:layout_marginHorizontal="15dp" | 174 | android:layout_marginHorizontal="15dp" |
174 | android:layout_width="match_parent" | 175 | android:layout_width="match_parent" |
175 | android:layout_height="wrap_content"/> | 176 | android:layout_height="wrap_content"/> |
176 | <TextView | 177 | |
177 | android:text="错题已经加入到错题本,到错题本查看详情" | 178 | <LinearLayout |
178 | android:textSize="12sp" | 179 | android:id="@+id/viewBlank" |
179 | android:textColor="#666" | 180 | android:orientation="horizontal" |
181 | android:layout_marginHorizontal="15dp" | ||
182 | android:layout_marginTop="15dp" | ||
183 | android:layout_width="match_parent" | ||
184 | android:layout_height="wrap_content"> | ||
185 | <TextView | ||
186 | android:text="未答题目" | ||
187 | android:textSize="14sp" | ||
188 | android:textColor="#333" | ||
189 | android:layout_width="wrap_content" | ||
190 | android:layout_height="wrap_content"/> | ||
191 | <TextView | ||
192 | android:id="@+id/btnDetail2" | ||
193 | android:text="(点击查看题目详情)" | ||
194 | android:textSize="14sp" | ||
195 | android:textColor="#1C90F3" | ||
196 | android:layout_width="wrap_content" | ||
197 | android:layout_height="wrap_content"/> | ||
198 | </LinearLayout> | ||
199 | |||
200 | <androidx.recyclerview.widget.RecyclerView | ||
201 | android:id="@+id/rvBlank" | ||
202 | tools:listitem="@layout/item_feedback_num" | ||
203 | tools:itemCount="1" | ||
204 | android:layout_marginTop="15dp" | ||
180 | android:layout_marginHorizontal="15dp" | 205 | android:layout_marginHorizontal="15dp" |
181 | android:layout_width="wrap_content" | 206 | android:layout_width="match_parent" |
182 | android:layout_height="wrap_content"/> | 207 | android:layout_height="wrap_content"/> |
183 | </LinearLayout> | 208 | </LinearLayout> |
184 | 209 | ||
185 | <LinearLayout | 210 | <LinearLayout |
186 | android:id="@+id/flEval" | 211 | android:id="@+id/flEval" |
187 | android:orientation="vertical" | 212 | android:orientation="vertical" |
188 | android:background="@drawable/shape_radius_10" | 213 | android:background="@drawable/shape_radius_10" |
189 | android:backgroundTint="@color/white" | 214 | android:backgroundTint="@color/white" |
190 | android:layout_marginTop="15dp" | 215 | android:layout_marginTop="15dp" |
191 | android:paddingBottom="16dp" | 216 | android:paddingBottom="16dp" |
192 | android:layout_width="match_parent" | 217 | android:layout_width="match_parent" |
193 | android:layout_height="wrap_content"> | 218 | android:layout_height="wrap_content"> |
194 | <androidx.appcompat.widget.AppCompatTextView | 219 | <androidx.appcompat.widget.AppCompatTextView |
195 | android:text="辅导后错题掌握评估" | 220 | android:text="辅导后错题掌握评估" |
196 | android:textSize="16sp" | 221 | android:textSize="16sp" |
197 | android:textColor="#333" | 222 | android:textColor="#333" |
198 | android:textStyle="bold" | 223 | android:textStyle="bold" |
199 | android:gravity="center_vertical" | 224 | android:gravity="center_vertical" |
200 | android:paddingHorizontal="15dp" | 225 | android:paddingHorizontal="15dp" |
201 | android:drawablePadding="5dp" | 226 | android:drawablePadding="5dp" |
202 | android:drawableStart="@drawable/svg_ic_paper" | 227 | android:drawableStart="@drawable/svg_ic_paper" |
203 | android:background="@drawable/shape_radius_top_10" | 228 | android:background="@drawable/shape_radius_top_10" |
204 | android:backgroundTint="#DAEBFE" | 229 | android:backgroundTint="#DAEBFE" |
205 | android:layout_width="match_parent" | 230 | android:layout_width="match_parent" |
206 | android:layout_height="40dp"/> | 231 | android:layout_height="40dp"/> |
207 | <androidx.recyclerview.widget.RecyclerView | 232 | <androidx.recyclerview.widget.RecyclerView |
208 | android:id="@+id/rvError" | 233 | android:id="@+id/rvError" |
209 | android:orientation="vertical" | 234 | android:orientation="vertical" |
210 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 235 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
211 | android:layout_width="match_parent" | 236 | android:layout_width="match_parent" |
212 | android:layout_height="wrap_content"/> | 237 | android:layout_height="wrap_content"/> |
213 | </LinearLayout> | 238 | </LinearLayout> |
214 | 239 | ||
215 | <LinearLayout | 240 | <LinearLayout |
216 | android:orientation="vertical" | 241 | android:orientation="vertical" |
217 | android:background="@drawable/shape_radius_10" | 242 | android:background="@drawable/shape_radius_10" |
218 | android:backgroundTint="@color/white" | 243 | android:backgroundTint="@color/white" |
219 | android:layout_marginTop="15dp" | 244 | android:layout_marginTop="15dp" |
220 | android:layout_width="match_parent" | 245 | android:layout_width="match_parent" |
221 | android:layout_height="wrap_content"> | 246 | android:layout_height="wrap_content"> |
222 | <androidx.appcompat.widget.AppCompatTextView | 247 | <androidx.appcompat.widget.AppCompatTextView |
223 | android:text="教师评语" | 248 | android:text="教师评语" |
224 | android:textSize="16sp" | 249 | android:textSize="16sp" |
225 | android:textColor="#333" | 250 | android:textColor="#333" |
226 | android:textStyle="bold" | 251 | android:textStyle="bold" |
227 | android:gravity="center_vertical" | 252 | android:gravity="center_vertical" |
228 | android:paddingHorizontal="15dp" | 253 | android:paddingHorizontal="15dp" |
229 | android:drawablePadding="5dp" | 254 | android:drawablePadding="5dp" |
230 | android:drawableStart="@drawable/svg_ic_comment" | 255 | android:drawableStart="@drawable/svg_ic_comment" |
231 | android:background="@drawable/shape_radius_top_10" | 256 | android:background="@drawable/shape_radius_top_10" |
232 | android:backgroundTint="#DAEBFE" | 257 | android:backgroundTint="#DAEBFE" |
233 | android:layout_width="match_parent" | 258 | android:layout_width="match_parent" |
234 | android:layout_height="40dp"/> | 259 | android:layout_height="40dp"/> |
235 | <EditText | 260 | <EditText |
236 | android:id="@+id/etComment" | 261 | android:id="@+id/etComment" |
237 | android:hint="非必填, 不超过300字" | 262 | android:hint="非必填, 不超过300字" |
238 | android:maxLength="300" | 263 | android:maxLength="300" |
239 | android:textSize="13sp" | 264 | android:textSize="13sp" |
240 | android:textColor="#333" | 265 | android:textColor="#333" |
241 | android:textColorHint="#999" | 266 | android:textColorHint="#999" |
242 | android:gravity="start" | 267 | android:gravity="start" |
243 | android:background="@null" | 268 | android:background="@null" |
244 | android:layout_margin="14dp" | 269 | android:layout_margin="14dp" |
245 | android:layout_width="match_parent" | 270 | android:layout_width="match_parent" |
246 | android:layout_height="wrap_content" | 271 | android:layout_height="wrap_content" |
247 | tools:ignore="Autofill,LabelFor,TextFields" /> | 272 | tools:ignore="Autofill,LabelFor,TextFields" /> |
248 | </LinearLayout> | 273 | </LinearLayout> |
249 | 274 | ||
250 | 275 | ||
251 | </LinearLayout> | 276 | </LinearLayout> |
252 | </androidx.core.widget.NestedScrollView> | 277 | </androidx.core.widget.NestedScrollView> |
253 | </LinearLayout> | 278 | </LinearLayout> |
app/src/main/res/layout/activity_homework_select.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout | 2 | <LinearLayout |
3 | xmlns:android="http://schemas.android.com/apk/res/android" | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
4 | xmlns:app="http://schemas.android.com/apk/res-auto" | 4 | xmlns:app="http://schemas.android.com/apk/res-auto" |
5 | xmlns:tools="http://schemas.android.com/tools" | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
7 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
8 | android:layout_height="match_parent" | 8 | android:layout_height="match_parent" |
9 | tools:ignore="HardcodedText"> | 9 | tools:ignore="HardcodedText"> |
10 | 10 | ||
11 | <androidx.appcompat.widget.Toolbar | 11 | <androidx.appcompat.widget.Toolbar |
12 | android:id="@+id/toolbar" | 12 | android:id="@+id/toolbar" |
13 | app:navigationIcon="@drawable/svg_back" | 13 | app:navigationIcon="@drawable/svg_back" |
14 | app:contentInsetStartWithNavigation="14dp" | 14 | app:contentInsetStartWithNavigation="14dp" |
15 | android:paddingStart="-8dp" | 15 | android:paddingStart="-8dp" |
16 | android:paddingEnd="-8dp" | 16 | android:paddingEnd="-8dp" |
17 | android:background="@color/white" | 17 | android:background="@color/white" |
18 | android:layout_width="match_parent" | 18 | android:layout_width="match_parent" |
19 | android:layout_height="40dp"> | 19 | android:layout_height="40dp"> |
20 | <TextView | 20 | <TextView |
21 | android:text="第一步:选择错题" | 21 | android:text="第一步:选择错题" |
22 | android:textSize="18sp" | 22 | android:textSize="18sp" |
23 | android:textColor="#333" | 23 | android:textColor="#333" |
24 | android:textStyle="bold" | 24 | android:textStyle="bold" |
25 | android:layout_gravity="center" | 25 | android:layout_gravity="center" |
26 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
27 | android:layout_height="wrap_content"/> | 27 | android:layout_height="wrap_content"/> |
28 | </androidx.appcompat.widget.Toolbar> | 28 | </androidx.appcompat.widget.Toolbar> |
29 | 29 | ||
30 | <LinearLayout | 30 | <LinearLayout |
31 | android:orientation="horizontal" | 31 | android:orientation="horizontal" |
32 | android:layout_marginHorizontal="16dp" | 32 | android:layout_marginHorizontal="16dp" |
33 | android:layout_marginTop="16dp" | 33 | android:layout_marginTop="16dp" |
34 | android:layout_marginBottom="8dp" | 34 | android:layout_marginBottom="8dp" |
35 | android:layout_width="match_parent" | 35 | android:layout_width="match_parent" |
36 | android:layout_height="wrap_content"> | 36 | android:layout_height="wrap_content"> |
37 | <CheckBox | 37 | <Space style="@style/empty_space"/> |
38 | android:id="@+id/chkAll" | 38 | <TextView |
39 | android:text="全选" | 39 | android:id="@+id/tvNumber" |
40 | android:text="0" | ||
40 | android:textSize="13sp" | 41 | android:textSize="13sp" |
41 | android:textColor="#333" | 42 | android:textColor="#1C90F3" |
42 | android:button="@drawable/chk_circle" | ||
43 | android:gravity="center_vertical" | ||
44 | android:paddingStart="8dp" | ||
45 | android:paddingEnd="0dp" | ||
46 | android:layout_width="wrap_content" | 43 | android:layout_width="wrap_content" |
47 | android:layout_height="wrap_content"/> | 44 | android:layout_height="wrap_content"/> |
48 | <Space style="@style/empty_space"/> | ||
49 | <TextView | 45 | <TextView |
50 | android:text="已选择 " | 46 | android:text=" 道错题, " |
51 | android:textSize="13sp" | 47 | android:textSize="13sp" |
52 | android:textColor="#333" | 48 | android:textColor="#333" |
53 | android:layout_width="wrap_content" | 49 | android:layout_width="wrap_content" |
54 | android:layout_height="wrap_content"/> | 50 | android:layout_height="wrap_content"/> |
55 | <TextView | 51 | <TextView |
56 | android:id="@+id/tvNumber" | 52 | android:id="@+id/tvBlankNumber" |
57 | android:text="0" | 53 | android:text="0" |
58 | android:textSize="13sp" | 54 | android:textSize="13sp" |
59 | android:textColor="#1C90F3" | 55 | android:textColor="#1C90F3" |
60 | android:layout_width="wrap_content" | 56 | android:layout_width="wrap_content" |
61 | android:layout_height="wrap_content"/> | 57 | android:layout_height="wrap_content"/> |
62 | <TextView | 58 | <TextView |
63 | android:text=" 道错题" | 59 | android:text=" 道未做题" |
64 | android:textSize="13sp" | 60 | android:textSize="13sp" |
65 | android:textColor="#333" | 61 | android:textColor="#333" |
66 | android:layout_width="wrap_content" | 62 | android:layout_width="wrap_content" |
67 | android:layout_height="wrap_content"/> | 63 | android:layout_height="wrap_content"/> |
68 | </LinearLayout> | 64 | </LinearLayout> |
69 | 65 | ||
70 | <androidx.recyclerview.widget.RecyclerView | 66 | <androidx.recyclerview.widget.RecyclerView |
71 | android:id="@+id/recyclerView" | 67 | android:id="@+id/recyclerView" |
72 | android:orientation="vertical" | 68 | android:orientation="vertical" |
73 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 69 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
74 | android:layout_width="match_parent" | 70 | android:layout_width="match_parent" |
75 | android:layout_height="0px" | 71 | android:layout_height="0px" |
76 | android:layout_weight="1"/> | 72 | android:layout_weight="1"/> |
77 | 73 | ||
78 | <FrameLayout | 74 | <FrameLayout |
79 | android:background="@color/white" | 75 | android:background="@color/white" |
80 | android:paddingTop="8dp" | 76 | android:paddingTop="8dp" |
81 | android:paddingBottom="16dp" | 77 | android:paddingBottom="16dp" |
82 | android:layout_width="match_parent" | 78 | android:layout_width="match_parent" |
83 | android:layout_height="wrap_content"> | 79 | android:layout_height="wrap_content"> |
84 | <TextView | 80 | <TextView |
85 | android:id="@+id/btnConfirm" | 81 | android:id="@+id/btnConfirm" |
86 | android:text="作业全对" | 82 | android:text="下一步" |
87 | android:textSize="16sp" | 83 | android:textSize="16sp" |
88 | android:textColor="@color/white" | 84 | android:textColor="@color/white" |
89 | android:gravity="center" | 85 | android:gravity="center" |
90 | android:layout_gravity="center" | 86 | android:layout_gravity="center" |
91 | android:background="@drawable/shape_radius_5" | 87 | android:background="@drawable/shape_radius_5" |
92 | android:backgroundTint="#4ABC78" | 88 | android:backgroundTint="#1C90F3" |
93 | android:layout_width="265dp" | 89 | android:layout_width="265dp" |
94 | android:layout_height="36dp"/> | 90 | android:layout_height="36dp"/> |
95 | </FrameLayout> | 91 | </FrameLayout> |
app/src/main/res/layout/item_homework_detail.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout | 2 | <LinearLayout |
3 | xmlns:android="http://schemas.android.com/apk/res/android" | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | android:id="@+id/root" | ||
5 | android:orientation="vertical" | 6 | android:orientation="vertical" |
6 | android:background="@drawable/shape_radius_10" | 7 | android:background="@drawable/shape_radius_10" |
7 | android:backgroundTint="@color/white" | ||
8 | android:paddingVertical="14dp" | 8 | android:paddingVertical="14dp" |
9 | android:layout_marginHorizontal="16dp" | 9 | android:layout_marginHorizontal="16dp" |
10 | android:layout_marginVertical="8dp" | 10 | android:layout_marginVertical="8dp" |
11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
12 | android:layout_height="wrap_content" | 12 | android:layout_height="wrap_content" |
13 | tools:ignore="SmallSp"> | 13 | tools:ignore="SmallSp,HardcodedText"> |
14 | 14 | ||
15 | <LinearLayout | 15 | <LinearLayout |
16 | android:orientation="horizontal" | 16 | android:orientation="horizontal" |
17 | android:gravity="center_vertical" | 17 | android:gravity="center_vertical" |
18 | android:layout_marginStart="16dp" | 18 | android:layout_marginStart="16dp" |
19 | android:layout_width="match_parent" | 19 | android:layout_width="match_parent" |
20 | android:layout_height="wrap_content"> | 20 | android:layout_height="wrap_content"> |
21 | <CheckBox | 21 | <CheckBox |
22 | android:id="@+id/checkbox" | 22 | android:id="@+id/checkbox" |
23 | android:visibility="gone" | 23 | android:visibility="gone" |
24 | tools:visibility="visible" | 24 | tools:visibility="visible" |
25 | android:button="@drawable/chk_circle" | 25 | android:button="@drawable/chk_circle" |
26 | android:layout_marginEnd="5dp" | 26 | android:layout_marginEnd="5dp" |
27 | android:layout_width="16dp" | 27 | android:layout_width="16dp" |
28 | android:layout_height="16dp"/> | 28 | android:layout_height="16dp"/> |
29 | <TextView | 29 | <TextView |
30 | android:id="@+id/tvNumber" | 30 | android:id="@+id/tvNumber" |
31 | tools:text="第1题" | 31 | tools:text="第1题" |
32 | android:textSize="9sp" | 32 | android:textSize="9sp" |
33 | android:textColor="@color/white" | 33 | android:textColor="@color/white" |
34 | android:paddingHorizontal="7dp" | 34 | android:paddingHorizontal="7dp" |
35 | android:paddingVertical="3dp" | 35 | android:paddingVertical="3dp" |
36 | android:background="@drawable/shape_radius_5" | 36 | android:background="@drawable/shape_radius_5" |
37 | android:backgroundTint="#489AFA" | 37 | android:backgroundTint="#489AFA" |
38 | android:layout_width="wrap_content" | 38 | android:layout_width="wrap_content" |
39 | android:layout_height="wrap_content" /> | 39 | android:layout_height="wrap_content" /> |
40 | <Space style="@style/empty_space"/> | ||
41 | <RadioGroup | ||
42 | android:id="@+id/radioGroup" | ||
43 | android:visibility="gone" | ||
44 | tools:visibility="visible" | ||
45 | android:orientation="horizontal" | ||
46 | android:weightSum="3" | ||
47 | android:gravity="center_vertical" | ||
48 | android:paddingHorizontal="10dp" | ||
49 | android:layout_gravity="bottom" | ||
50 | android:layout_width="wrap_content" | ||
51 | android:layout_height="wrap_content"> | ||
52 | <RadioButton | ||
53 | android:id="@+id/rbRight" | ||
54 | android:text="正确" | ||
55 | android:textSize="12sp" | ||
56 | android:textColor="@color/white" | ||
57 | android:gravity="center" | ||
58 | android:button="@null" | ||
59 | android:background="@drawable/btn_feedback_right" | ||
60 | android:layout_marginHorizontal="8dp" | ||
61 | android:layout_width="64dp" | ||
62 | android:layout_height="20dp" /> | ||
63 | <RadioButton | ||
64 | android:id="@+id/rbError" | ||
65 | android:text="错误" | ||
66 | android:textSize="12sp" | ||
67 | android:textColor="@color/white" | ||
68 | android:gravity="center" | ||
69 | android:button="@null" | ||
70 | android:background="@drawable/btn_feedback_error" | ||
71 | android:layout_marginHorizontal="8dp" | ||
72 | android:layout_width="64dp" | ||
73 | android:layout_height="20dp" /> | ||
74 | <RadioButton | ||
75 | android:id="@+id/rbBlank" | ||
76 | android:text="未完成" | ||
77 | android:textSize="12sp" | ||
78 | android:textColor="@color/white" | ||
79 | android:gravity="center" | ||
80 | android:button="@null" | ||
81 | android:background="@drawable/btn_feedback_blank" | ||
82 | android:layout_marginHorizontal="8dp" | ||
83 | android:layout_width="64dp" | ||
84 | android:layout_height="20dp" /> | ||
85 | </RadioGroup> | ||
40 | </LinearLayout> | 86 | </LinearLayout> |
41 | 87 | ||
42 | <ImageView | 88 | <ImageView |
43 | android:id="@+id/ivTopic" | 89 | android:id="@+id/ivTopic" |
44 | android:adjustViewBounds="true" | 90 | android:adjustViewBounds="true" |
45 | android:layout_marginStart="10dp" | 91 | android:layout_marginHorizontal="10dp" |
46 | android:layout_marginEnd="4dp" | ||
47 | android:layout_marginTop="14dp" | 92 | android:layout_marginTop="14dp" |
48 | android:layout_width="match_parent" | 93 | android:layout_width="match_parent" |
49 | android:layout_height="wrap_content" | 94 | android:layout_height="wrap_content" |
libs/common/src/main/java/com/prws/common/bean/homework/Correction.java
1 | package com.prws.common.bean.homework; | File was deleted | |
2 | |||
3 | public class Correction { | ||
4 | |||
5 | public String brief; | ||
6 | |||
7 | public int correction; // 0 对, 1 错 | ||
8 | |||
9 | public Correction() { | ||
10 | } | ||
11 | |||
12 | public Correction(String brief, int correction) { | ||
13 | this.brief = brief; | ||
14 | this.correction = correction; | ||
15 | } | ||
16 | } | ||
17 | 1 | package com.prws.common.bean.homework; |
libs/common/src/main/java/com/prws/common/bean/homework/CorrectionSer.java
1 | package com.prws.common.bean.homework; | 1 | package com.prws.common.bean.homework; |
2 | 2 | ||
3 | public class CorrectionSer { | 3 | public class CorrectionSer { |
4 | public String brief; | 4 | public String brief; |
5 | public int correction; // 0 对, 1 错 | 5 | public int correction; // 0 对, 1 错, 2 未做题 |
6 | public int state; // 1: 已听懂; 2: 基本听懂; 3: 一般听懂 | 6 | public int state; // 1: 已听懂; 2: 基本听懂; 3: 一般听懂 |
7 | 7 | ||
8 | public CorrectionSer() { | 8 | public CorrectionSer() { |
9 | } | 9 | } |
10 | 10 | ||
11 | public CorrectionSer(String brief, int correction, int state) { | 11 | public CorrectionSer(String brief, int correction, int state) { |
12 | this.brief = brief; | 12 | this.brief = brief; |
13 | this.correction = correction; | 13 | this.correction = correction; |
14 | this.state = state; | 14 | this.state = state; |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 |
libs/common/src/main/java/com/prws/common/bean/homework/HomeWork.java
1 | package com.prws.common.bean.homework; | 1 | package com.prws.common.bean.homework; |
2 | 2 | ||
3 | import com.google.gson.Gson; | 3 | import com.google.gson.Gson; |
4 | import com.google.gson.annotations.SerializedName; | 4 | import com.google.gson.annotations.SerializedName; |
5 | import com.google.gson.reflect.TypeToken; | 5 | import com.google.gson.reflect.TypeToken; |
6 | 6 | ||
7 | import java.io.Serializable; | 7 | import java.io.Serializable; |
8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
9 | import java.util.List; | 9 | import java.util.List; |
10 | 10 | ||
11 | public class HomeWork implements Serializable { | 11 | public class HomeWork implements Serializable { |
12 | 12 | ||
13 | @SerializedName(value = "homeworkId", alternate = "id") | 13 | @SerializedName(value = "homeworkId", alternate = "id") |
14 | public String homeworkId; | 14 | public String homeworkId; |
15 | public String brief; | 15 | public String brief; |
16 | public String url; | 16 | public String url; |
17 | public String analyseUrl; | 17 | public String analyseUrl; |
18 | public String analyseVideoUrl; | 18 | public String analyseVideoUrl; |
19 | public Integer correction; | 19 | public Integer correction; |
20 | public String answer; | 20 | public String answer; |
21 | public String points; | 21 | public String points; |
22 | 22 | ||
23 | public boolean check = false; //选中为错题 | ||
24 | public transient int index = 0; | 23 | public transient int index = 0; |
25 | public transient int state = 1; | 24 | public transient int state = 1; |
26 | 25 | ||
27 | public transient List<KeyValue> pointsObj; | 26 | public transient List<KeyValue> pointsObj; |
28 | public void formatPoints(Gson gson) { | 27 | public void formatPoints(Gson gson) { |
29 | if (points == null) { | 28 | if (points == null) { |
30 | pointsObj = new ArrayList<>(); | 29 | pointsObj = new ArrayList<>(); |
31 | return; | 30 | return; |
32 | } | 31 | } |
33 | try { | 32 | try { |
34 | pointsObj = gson.fromJson(points, new TypeToken<List<KeyValue>>(){}.getType()); | 33 | pointsObj = gson.fromJson(points, new TypeToken<List<KeyValue>>(){}.getType()); |
35 | } catch (Exception e) { | 34 | } catch (Exception e) { |
36 | e.printStackTrace(); | 35 | e.printStackTrace(); |
37 | pointsObj = new ArrayList<>(); | 36 | pointsObj = new ArrayList<>(); |
38 | } | 37 | } |
39 | } | 38 | } |
40 | 39 | ||
41 | public CorrectionSer toSer() { | 40 | public CorrectionSer toSer() { |
42 | return new CorrectionSer(brief, check ? 1 : 0, state); | 41 | return new CorrectionSer(brief, correction, state); |
43 | } | 42 | } |
44 | } | 43 | } |
45 | 44 |
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.User; | 16 | import com.prws.common.bean.User; |
17 | import com.prws.common.bean.baidu.BaiduInput; | 17 | import com.prws.common.bean.baidu.BaiduInput; |
18 | import com.prws.common.bean.homework.HomeWork; | 18 | import com.prws.common.bean.homework.HomeWork; |
19 | import com.prws.common.bean.homework.HomeworkDetail; | 19 | import com.prws.common.bean.homework.HomeworkDetail; |
20 | import com.prws.common.bean.homework.HomeworkList; | 20 | import com.prws.common.bean.homework.HomeworkList; |
21 | import com.prws.common.bean.homework.StDetail; | 21 | import com.prws.common.bean.homework.StDetail; |
22 | import com.prws.common.utils.BitmapUtils; | 22 | import com.prws.common.utils.BitmapUtils; |
23 | import com.prws.common.utils.SharedPreferencesUtil; | 23 | import com.prws.common.utils.SharedPreferencesUtil; |
24 | 24 | ||
25 | import java.io.File; | 25 | import java.io.File; |
26 | import java.util.HashMap; | 26 | import java.util.HashMap; |
27 | import java.util.List; | 27 | import java.util.List; |
28 | import java.util.Map; | 28 | import java.util.Map; |
29 | 29 | ||
30 | import io.reactivex.Observable; | 30 | import io.reactivex.Observable; |
31 | import io.reactivex.Observer; | 31 | import io.reactivex.Observer; |
32 | import io.reactivex.Single; | 32 | import io.reactivex.Single; |
33 | import io.reactivex.android.schedulers.AndroidSchedulers; | 33 | import io.reactivex.android.schedulers.AndroidSchedulers; |
34 | import io.reactivex.schedulers.Schedulers; | 34 | import io.reactivex.schedulers.Schedulers; |
35 | import okhttp3.MediaType; | 35 | import okhttp3.MediaType; |
36 | import okhttp3.MultipartBody; | 36 | import okhttp3.MultipartBody; |
37 | import okhttp3.RequestBody; | 37 | import okhttp3.RequestBody; |
38 | import okhttp3.ResponseBody; | 38 | import okhttp3.ResponseBody; |
39 | import retrofit2.Call; | 39 | import retrofit2.Call; |
40 | import retrofit2.Callback; | 40 | import retrofit2.Callback; |
41 | import retrofit2.http.Body; | 41 | import retrofit2.http.Body; |
42 | import retrofit2.http.GET; | 42 | import retrofit2.http.GET; |
43 | import retrofit2.http.Header; | 43 | import retrofit2.http.Header; |
44 | import retrofit2.http.Headers; | 44 | import retrofit2.http.Headers; |
45 | import retrofit2.http.Multipart; | 45 | import retrofit2.http.Multipart; |
46 | import retrofit2.http.POST; | 46 | import retrofit2.http.POST; |
47 | import retrofit2.http.PUT; | 47 | import retrofit2.http.PUT; |
48 | import retrofit2.http.Part; | 48 | import retrofit2.http.Part; |
49 | import retrofit2.http.PartMap; | 49 | import retrofit2.http.PartMap; |
50 | import retrofit2.http.Query; | 50 | import retrofit2.http.Query; |
51 | import retrofit2.http.Url; | 51 | import retrofit2.http.Url; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * 类名称:NetWorks | 54 | * 类名称:NetWorks |
55 | * 创建人: | 55 | * 创建人: |
56 | * <p> | 56 | * <p> |
57 | * 类描述:网络请求的操作类 | 57 | * 类描述:网络请求的操作类 |
58 | */ | 58 | */ |
59 | public class NetWorks extends RetrofitUtils { | 59 | public class NetWorks extends RetrofitUtils { |
60 | //服务器路径 | 60 | //服务器路径 |
61 | public static final NetService service_url = getMachineRetrofit("https://mgr.hjx.com").create(NetService.class); | 61 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); |
62 | 62 | ||
63 | //设缓存有效期为1天 | 63 | //设缓存有效期为1天 |
64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | 64 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; |
65 | //查询缓存的Cache-Control设置,使用缓存 | 65 | //查询缓存的Cache-Control设置,使用缓存 |
66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | 66 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; |
67 | //查询网络的Cache-Control设置。不使用缓存 | 67 | //查询网络的Cache-Control设置。不使用缓存 |
68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | 68 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
69 | 69 | ||
70 | 70 | ||
71 | public interface NetService { | 71 | public interface NetService { |
72 | 72 | ||
73 | 73 | ||
74 | @GET("/api/v1/user/logout") | 74 | @GET("/api/v1/user/logout") |
75 | Observable<ResponseBody> logout(); | 75 | Observable<ResponseBody> logout(); |
76 | 76 | ||
77 | @Multipart | 77 | @Multipart |
78 | @POST("/api/v1/user/upLoadAvatar") | 78 | @POST("/api/v1/user/upLoadAvatar") |
79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); | 79 | Observable<ResponseBody> upLoadAvatar(@Header("Authorization") String token, @Part List<MultipartBody.Part> partLis); |
80 | 80 | ||
81 | 81 | ||
82 | @Headers("Content-Type: application/json") | 82 | @Headers("Content-Type: application/json") |
83 | @POST("/api/v1/user/editUser") | 83 | @POST("/api/v1/user/editUser") |
84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); | 84 | Observable<ResponseBody> editUser(@Header("Authorization") String token, @Body RequestBody body); |
85 | 85 | ||
86 | @Headers("Content-Type: application/json") | 86 | @Headers("Content-Type: application/json") |
87 | @POST("/api/v1/user/changePassword") | 87 | @POST("/api/v1/user/changePassword") |
88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); | 88 | Observable<ResponseBody> changePassword(@Header("Authorization") String token, @Body RequestBody body); |
89 | 89 | ||
90 | 90 | ||
91 | @GET("/api/v1/user/searchById") | 91 | @GET("/api/v1/user/searchById") |
92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); | 92 | Observable<ResponseBody> searchById(@Header("Authorization") String token, @Query("userId") String userId); |
93 | 93 | ||
94 | 94 | ||
95 | @Headers("Content-Type: application/json") | 95 | @Headers("Content-Type: application/json") |
96 | @POST("/api/v1/login/userLogin") | 96 | @POST("/api/v1/login/userLogin") |
97 | Observable<ResponseBody> login(@Body RequestBody body); | 97 | Observable<ResponseBody> login(@Body RequestBody body); |
98 | 98 | ||
99 | @GET("/api/v1/resource/listGradeAndSubject") | 99 | @GET("/api/v1/resource/listGradeAndSubject") |
100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); | 100 | Observable<ResponseResult<List<GradeAndSubject>>> listGradeAndSubject(@Header("Authorization") String token); |
101 | 101 | ||
102 | 102 | ||
103 | @GET("/api/v1/manager/generalQrCode") | 103 | @GET("/api/v1/manager/generalQrCode") |
104 | Observable<ResponseBody> generalQrCode(); | 104 | Observable<ResponseBody> generalQrCode(); |
105 | 105 | ||
106 | @GET("/api/v1/parent/scanAndLogin") | 106 | @GET("/api/v1/parent/scanAndLogin") |
107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); | 107 | Observable<ResponseBody> scanAndLogin(@Header("Authorization") String token, @Query("code") String code, @Query("stuId") String stuId); |
108 | 108 | ||
109 | @GET("/api/v1/parent/getChildrenList") | 109 | @GET("/api/v1/parent/getChildrenList") |
110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); | 110 | Observable<ResponseBody> getChildrenList(@Header("Authorization") String token); |
111 | 111 | ||
112 | 112 | ||
113 | @Headers("Content-Type: application/json") | 113 | @Headers("Content-Type: application/json") |
114 | @POST("/api/v1/parent/registerParent") | 114 | @POST("/api/v1/parent/registerParent") |
115 | Observable<ResponseBody> registerParent(@Body RequestBody body); | 115 | Observable<ResponseBody> registerParent(@Body RequestBody body); |
116 | 116 | ||
117 | 117 | ||
118 | @GET("/api/v1/parent/listChildren") | 118 | @GET("/api/v1/parent/listChildren") |
119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); | 119 | Observable<ResponseBody> listChildren(@Header("Authorization") String token); |
120 | 120 | ||
121 | 121 | ||
122 | @Headers("Content-Type: application/json") | 122 | @Headers("Content-Type: application/json") |
123 | @POST("/api/v1/parent/registerStudent") | 123 | @POST("/api/v1/parent/registerStudent") |
124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); | 124 | Observable<ResponseBody> registerStudent(@Header("Authorization") String token, @Body RequestBody body); |
125 | 125 | ||
126 | @Headers("Content-Type: application/json") | 126 | @Headers("Content-Type: application/json") |
127 | @POST("/api/v1/parent/bindTeacher") | 127 | @POST("/api/v1/parent/bindTeacher") |
128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); | 128 | Observable<ResponseBody> bindTeacher(@Header("Authorization") String token, @Body RequestBody body); |
129 | 129 | ||
130 | @Multipart | 130 | @Multipart |
131 | @POST("/api/v1/user/upLoadAvatar") | 131 | @POST("/api/v1/user/upLoadAvatar") |
132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); | 132 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file); |
133 | 133 | ||
134 | 134 | ||
135 | @Multipart | 135 | @Multipart |
136 | @POST("/api/v1/student/editStudentAvatar") | 136 | @POST("/api/v1/student/editStudentAvatar") |
137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 137 | Observable<ResponseResult<Map<String, String>>> uploadAvatar(@Header("Authorization") String token, @Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
138 | 138 | ||
139 | @Headers("Content-Type: application/json") | 139 | @Headers("Content-Type: application/json") |
140 | @POST("/api/v1/parent/editChild") | 140 | @POST("/api/v1/parent/editChild") |
141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); | 141 | Observable<ResponseResult> editStudent(@Header("Authorization") String token, @Body RequestBody body); |
142 | 142 | ||
143 | @GET("/api/v1/student/getStudyPlanForThisWeek") | 143 | @GET("/api/v1/student/getStudyPlanForThisWeek") |
144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); | 144 | Observable<ResponseResult<ScheduleBean>> getWeekPlan(@Header("Authorization") String token, @Query("stuId") String stuId); |
145 | 145 | ||
146 | @GET("api/v1/parent/searchTeacher") | 146 | @GET("api/v1/parent/searchTeacher") |
147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); | 147 | Observable<ResponseResult<Teacher>> searchTeacher(@Header("Authorization") String token, @Query("phone") String phone); |
148 | 148 | ||
149 | @POST("api/v1/question/listErrorBook") | 149 | @POST("api/v1/question/listErrorBook") |
150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); | 150 | Observable<ResponseResult<PageInfo<TopicBean>>> getError(@Header("Authorization") String token, @Body Map<String, Object> body); |
151 | 151 | ||
152 | @POST | 152 | @POST |
153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); | 153 | Observable<JsonObject> removeWriting(@Url String url, @Body RequestBody body); |
154 | 154 | ||
155 | @POST | 155 | @POST |
156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); | 156 | Observable<CutPicBean> cut(@Url String url, @Body RequestBody body); |
157 | 157 | ||
158 | @POST | 158 | @POST |
159 | Observable<JsonObject> getBaiduToken(@Url String url); | 159 | Observable<JsonObject> getBaiduToken(@Url String url); |
160 | 160 | ||
161 | @Multipart | 161 | @Multipart |
162 | @POST("api/v1/pad/addErrorBook") | 162 | @POST("api/v1/pad/addErrorBook") |
163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); | 163 | Observable<ResponseResult> addError(@Part() MultipartBody.Part file, @PartMap Map<String, Object> map); |
164 | 164 | ||
165 | @POST("api/v1/pad/deleteStuErrorBook") | 165 | @POST("api/v1/pad/deleteStuErrorBook") |
166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); | 166 | Observable<ResponseResult> deleteError(@Header("Authorization") String token, @Body List<String> map); |
167 | 167 | ||
168 | @PUT("api/v1/pad/updateStuErrorBookInfo") | 168 | @PUT("api/v1/pad/updateStuErrorBookInfo") |
169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); | 169 | Observable<ResponseResult> updateError(@Header("Authorization") String token, @Body List<HashMap<String, Object>> map); |
170 | 170 | ||
171 | @POST("api/v1/question/editErrorBook") | 171 | @POST("api/v1/question/editErrorBook") |
172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); | 172 | Observable<ResponseResult> editError(@Header("Authorization") String Authorization, @Body Map<String, Object> map); |
173 | 173 | ||
174 | @GET("api/v1/resource/checkUpdate") | 174 | @GET("api/v1/resource/checkUpdate") |
175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); | 175 | Call<ResponseResult<UpdateBean>> checkUpdate(@Query("version") int version, @Query("packageName") String packageName, @Query("type") int type); |
176 | 176 | ||
177 | @GET("api/v1/teacher/getStudentList") | 177 | @GET("api/v1/teacher/getStudentList") |
178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); | 178 | Observable<ResponseBody> getStudentList(@Header("Authorization") String token, @Query("userId") String id); |
179 | 179 | ||
180 | @GET("api/v1/teacher/getStudentList") | 180 | @GET("api/v1/teacher/getStudentList") |
181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); | 181 | Single<ResponseResult<List<Student>>> getStudentList2(@Header("Authorization") String token, @Query("userId") String id); |
182 | 182 | ||
183 | @GET("api/v1/answer/listRecordForTeacher") | 183 | @GET("api/v1/answer/listRecordForTeacher") |
184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); | 184 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
185 | 185 | ||
186 | @GET("api/v1/homework/listHomeworkByStuId") | 186 | @GET("api/v1/homework/listHomeworkByStuId") |
187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | 187 | Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); |
188 | 188 | ||
189 | @POST | 189 | @POST |
190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); | 190 | Single<BaiduInput> inputImage(@Url String url, @Body RequestBody body); |
191 | 191 | ||
192 | @Multipart | 192 | @Multipart |
193 | @POST("api/v1/homework/uploadHomework") | 193 | @POST("api/v1/homework/uploadHomework") |
194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); | 194 | Single<ResponseResult> uploadImage(@Header("Authorization") String token, @Part() MultipartBody.Part file, @Query("brief") String id); |
195 | 195 | ||
196 | @POST("api/v1/homework/uploadHomeworkAction") | 196 | @POST("api/v1/homework/uploadHomeworkAction") |
197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); | 197 | Single<ResponseResult> uploadHomework(@Header("Authorization") String token, @Body Object map); |
198 | 198 | ||
199 | @GET("api/v1/homework/removeHomework") | 199 | @GET("api/v1/homework/removeHomework") |
200 | Single<ResponseResult<Boolean>> deleteHomework( | 200 | Single<ResponseResult<Boolean>> deleteHomework( |
201 | @Header("Authorization") String token, | 201 | @Header("Authorization") String token, |
202 | @Query("homeworkId") String homeworkId | 202 | @Query("homeworkId") String homeworkId |
203 | ); | 203 | ); |
204 | 204 | ||
205 | @GET("api/v1/homework/listHomeworkById") | 205 | @GET("api/v1/homework/listHomeworkById") |
206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); | 206 | Single<ResponseResult<List<HomeWork>>> getHomeworkDetail(@Header("Authorization") String token, @Query("homeworkId") String homeworkId); |
207 | 207 | ||
208 | @POST("api/v1/homework/uploadHomeworkFeedback") | 208 | @POST("api/v1/homework/uploadHomeworkFeedback") |
209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); | 209 | Single<ResponseResult> uploadHomeworkFeedback(@Header("Authorization") String token, @Body Map<String, Object> map); |
210 | 210 | ||
211 | @POST("api/v1/homework/editHomeworkInfo") | 211 | @POST("api/v1/homework/editHomeworkInfo") |
212 | Single<ResponseResult<Boolean>> editHomework( | 212 | Single<ResponseResult<Boolean>> editHomework( |
213 | @Header("Authorization") String token, | 213 | @Header("Authorization") String token, |
214 | @Body Object body | 214 | @Body Object body |
215 | ); | 215 | ); |
216 | 216 | ||
217 | @GET("api/v1/homework/listHomeworkDetailByStuId") | 217 | @GET("api/v1/homework/listHomeworkDetailByStuId") |
218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( | 218 | Single<ResponseResult<HomeworkDetail>> getHomeworkCompleteDetail( |
219 | @Header("Authorization") String token, | 219 | @Header("Authorization") String token, |
220 | @Query("stuId") String stuId, | 220 | @Query("stuId") String stuId, |
221 | @Query("homeworkId") String homeworkId, | 221 | @Query("homeworkId") String homeworkId, |
222 | // type 固定传true | 222 | // type 固定传true |
223 | @Query("type") boolean type | 223 | @Query("type") boolean type |
224 | ); | 224 | ); |
225 | 225 | ||
226 | @GET("api/v1/homework/listHomeworkStatistics") | 226 | @GET("api/v1/homework/listHomeworkStatistics") |
227 | Single<ResponseResult<List<StDetail>>> getHuyouList( | 227 | Single<ResponseResult<List<StDetail>>> getHuyouList( |
228 | @Header("Authorization") String token, | 228 | @Header("Authorization") String token, |
229 | @Query("stuId") String stuId, | 229 | @Query("stuId") String stuId, |
230 | @Query("type") int type //0: 周报, 1:阶段总结 | 230 | @Query("type") int type //0: 周报, 1:阶段总结 |
231 | ); | 231 | ); |
232 | 232 | ||
233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") | 233 | @GET("api/v1/homework/listHomeworkStatisticsDetailForStudent") |
234 | Single<ResponseResult<StDetail>> getHuyouDetail( | 234 | Single<ResponseResult<StDetail>> getHuyouDetail( |
235 | @Header("Authorization") String token, | 235 | @Header("Authorization") String token, |
236 | @Query("homeworkStatisticsId") String homeworkId | 236 | @Query("homeworkStatisticsId") String homeworkId |
237 | ); | 237 | ); |
238 | 238 | ||
239 | @GET("api/v1/demo/generalStatisticsHomework") | 239 | @GET("api/v1/demo/generalStatisticsHomework") |
240 | Single<ResponseResult<Object>> generalHuyou(); | 240 | Single<ResponseResult<Object>> generalHuyou(); |
241 | 241 | ||
242 | @POST("api/v1/homework/generalHomeworkStageStatistics") | 242 | @POST("api/v1/homework/generalHomeworkStageStatistics") |
243 | Single<ResponseResult<Boolean>> generalStageHuyou( | 243 | Single<ResponseResult<Boolean>> generalStageHuyou( |
244 | @Header("Authorization") String token, | 244 | @Header("Authorization") String token, |
245 | @Body Object body | 245 | @Body Object body |
246 | ); | 246 | ); |
247 | 247 | ||
248 | @GET("api/v1/homework/removeHomeworkStatistics") | 248 | @GET("api/v1/homework/removeHomeworkStatistics") |
249 | Single<ResponseResult<Boolean>> deleteHuyou( | 249 | Single<ResponseResult<Boolean>> deleteHuyou( |
250 | @Header("Authorization") String token, | 250 | @Header("Authorization") String token, |
251 | @Query("homeworkStatisticsId") String homeworkId | 251 | @Query("homeworkStatisticsId") String homeworkId |
252 | ); | 252 | ); |
253 | 253 | ||
254 | @GET("api/v1/login/smsCode") | 254 | @GET("api/v1/login/smsCode") |
255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); | 255 | Single<ResponseResult<String>> smsCode(@Query("mobile") String mobile); |
256 | 256 | ||
257 | @POST("api/v1/login/smsLogin") | 257 | @POST("api/v1/login/smsLogin") |
258 | Single<ResponseResult<User>> smsLogin(@Body Object body); | 258 | Single<ResponseResult<User>> smsLogin(@Body Object body); |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | public static String getUserId() { | 262 | public static String getUserId() { |
263 | return (String) SharedPreferencesUtil.getData("userId", ""); | 263 | return (String) SharedPreferencesUtil.getData("userId", ""); |
264 | } | 264 | } |
265 | 265 | ||
266 | public static String getHeader() { | 266 | public static String getHeader() { |
267 | return (String) SharedPreferencesUtil.getData("token", ""); | 267 | return (String) SharedPreferencesUtil.getData("token", ""); |
268 | } | 268 | } |
269 | 269 | ||
270 | public static String getBaiduToken() { | 270 | public static String getBaiduToken() { |
271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); | 271 | return (String) SharedPreferencesUtil.getData("baiduToken", ""); |
272 | } | 272 | } |
273 | 273 | ||
274 | public static Single<BaiduInput> inputImage(String filePath, String id) { | 274 | public static Single<BaiduInput> inputImage(String filePath, String id) { |
275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 275 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
276 | String base64 = BitmapUtils.fileToBase64(filePath); | 276 | String base64 = BitmapUtils.fileToBase64(filePath); |
277 | File file = new File(filePath); | 277 | File file = new File(filePath); |
278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); | 278 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&brief={\"name\":\"" + file.getName() + "\", \"id\":\"" + id + "\"}"); |
279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) | 279 | return getBaiduTokenOcr().map(jsonObject -> jsonObject.get("access_token").getAsString()) |
280 | .flatMap(token -> { | 280 | .flatMap(token -> { |
281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); | 281 | return service_url.inputImage("https://aip.baidubce.com/rest/2.0/realtime_search/same_hq/add?access_token=" + token, body); |
282 | }); | 282 | }); |
283 | } | 283 | } |
284 | 284 | ||
285 | public static Single<ResponseResult> uploadImage(String path, String id) { | 285 | public static Single<ResponseResult> uploadImage(String path, String id) { |
286 | File file = new File(path); | 286 | File file = new File(path); |
287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 287 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 288 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
289 | return service_url.uploadImage(getHeader(), part, id); | 289 | return service_url.uploadImage(getHeader(), part, id); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { | 293 | public static void checkUpdate(int code, String packageName, Callback<ResponseResult<UpdateBean>> callback) { |
294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); | 294 | service_url.checkUpdate(code, packageName, 0).enqueue(callback); |
295 | } | 295 | } |
296 | 296 | ||
297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { | 297 | public static void addError(String path, Map<String, String> param, Observer<ResponseResult> observer) { |
298 | File file = new File(path); | 298 | File file = new File(path); |
299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); | 299 | RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file); |
300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 300 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
301 | Map<String, Object> map = new HashMap<>(); | 301 | Map<String, Object> map = new HashMap<>(); |
302 | map.put("condition", param); | 302 | map.put("condition", param); |
303 | setSubscribe(service_url.addError(part, map), observer); | 303 | setSubscribe(service_url.addError(part, map), observer); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | public static void cut(String base64, Observer<CutPicBean> observer) { | 307 | public static void cut(String base64, Observer<CutPicBean> observer) { |
308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 308 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); | 309 | RequestBody body = RequestBody.create(mediaType, "image=" + base64 + "&detect_direction=true"); |
310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); | 310 | setSubscribe(service_url.cut("https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu?access_token=" + getBaiduToken(), body), observer); |
311 | } | 311 | } |
312 | 312 | ||
313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { | 313 | public static void editError(Map<String, Object> map, Observer<ResponseResult> observer) { |
314 | setSubscribe(service_url.editError(getHeader(), map), observer); | 314 | setSubscribe(service_url.editError(getHeader(), map), observer); |
315 | } | 315 | } |
316 | 316 | ||
317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { | 317 | public static void editError(List<HashMap<String, Object>> map, Observer<ResponseResult> observer) { |
318 | setSubscribe(service_url.updateError(getHeader(), map), observer); | 318 | setSubscribe(service_url.updateError(getHeader(), map), observer); |
319 | } | 319 | } |
320 | 320 | ||
321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { | 321 | public static void deleteError(List<String> map, Observer<ResponseResult> observer) { |
322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); | 322 | setSubscribe(service_url.deleteError(getHeader(), map), observer); |
323 | } | 323 | } |
324 | 324 | ||
325 | public static void getBaiduToken(Observer<JsonObject> observer) { | 325 | public static void getBaiduToken(Observer<JsonObject> observer) { |
326 | 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); | 326 | 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); |
327 | } | 327 | } |
328 | 328 | ||
329 | public static Single<JsonObject> getBaiduTokenOcr() { | 329 | public static Single<JsonObject> getBaiduTokenOcr() { |
330 | 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(); | 330 | 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(); |
331 | } | 331 | } |
332 | 332 | ||
333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { | 333 | public static void removeWriting(String base64, Observer<JsonObject> observer) { |
334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 334 | MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); |
335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); | 335 | RequestBody body = RequestBody.create(mediaType, "image=" + base64); |
336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); | 336 | setSubscribe(service_url.removeWriting(("https://aip.baidubce.com/rest/2.0/ocr/v1/remove_handwriting?access_token=" + getBaiduToken()), body), observer); |
337 | } | 337 | } |
338 | 338 | ||
339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { | 339 | public static void searchTeacher(String phone, Observer<ResponseResult<Teacher>> observer) { |
340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); | 340 | setSubscribe(service_url.searchTeacher(getHeader(), phone), observer); |
341 | } | 341 | } |
342 | 342 | ||
343 | public static void logout(Observer<ResponseBody> observer) { | 343 | public static void logout(Observer<ResponseBody> observer) { |
344 | setSubscribe(service_url.logout(), observer); | 344 | setSubscribe(service_url.logout(), observer); |
345 | } | 345 | } |
346 | 346 | ||
347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { | 347 | public static void editStudent(RequestBody body, Observer<ResponseResult> observable) { |
348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); | 348 | setSubscribe(service_url.editStudent(getHeader(), body), observable); |
349 | } | 349 | } |
350 | 350 | ||
351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { | 351 | public static void getWeekPlan(String id, Observer<ResponseResult<ScheduleBean>> observer) { |
352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); | 352 | setSubscribe(service_url.getWeekPlan(getHeader(), id), observer); |
353 | } | 353 | } |
354 | 354 | ||
355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { | 355 | public static void uploadStudentAvatar(File file, String stuId, Observer<ResponseResult<Map<String, String>>> observer) { |
356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 356 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 357 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
358 | Map<String, Object> map = new HashMap<>(); | 358 | Map<String, Object> map = new HashMap<>(); |
359 | map.put("stuId", stuId); | 359 | map.put("stuId", stuId); |
360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); | 360 | setSubscribe(service_url.uploadAvatar(getHeader(), part, map), observer); |
361 | } | 361 | } |
362 | 362 | ||
363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { | 363 | public static void uploadAvatar(File file, Observer<ResponseResult<Map<String, String>>> observer) { |
364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); | 364 | RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); |
365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); | 365 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody); |
366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); | 366 | setSubscribe(service_url.uploadAvatar(getHeader(), part), observer); |
367 | } | 367 | } |
368 | 368 | ||
369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { | 369 | public static void upLoadAvatar(List<MultipartBody.Part> partLis, Observer<ResponseBody> observer) { |
370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); | 370 | setSubscribe(service_url.upLoadAvatar(getHeader(), partLis), observer); |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { | 374 | public static void editUser(RequestBody body, Observer<ResponseBody> observer) { |
375 | setSubscribe(service_url.editUser(getHeader(), body), observer); | 375 | setSubscribe(service_url.editUser(getHeader(), body), observer); |
376 | } | 376 | } |
377 | 377 | ||
378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { | 378 | public static void changePassword(RequestBody body, Observer<ResponseBody> observer) { |
379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); | 379 | setSubscribe(service_url.changePassword(getHeader(), body), observer); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | public static void searchById(String userId, Observer<ResponseBody> observer) { | 383 | public static void searchById(String userId, Observer<ResponseBody> observer) { |
384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); | 384 | setSubscribe(service_url.searchById(getHeader(), userId), observer); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { | 388 | public static void login(RequestBody body, Observer<ResponseBody> observer) { |
389 | setSubscribe(service_url.login(body), observer); | 389 | setSubscribe(service_url.login(body), observer); |
390 | } | 390 | } |
391 | 391 | ||
392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { | 392 | public static void listGradeAndSubject(Observer<ResponseResult<List<GradeAndSubject>>> observer) { |
393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); | 393 | setSubscribe(service_url.listGradeAndSubject(getHeader()), observer); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { | 397 | public static void scanAndLogin(String code, String stuId, Observer<ResponseBody> observer) { |
398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); | 398 | setSubscribe(service_url.scanAndLogin(getHeader(), code, stuId), observer); |
399 | } | 399 | } |
400 | 400 | ||
401 | public static void getChildrenList(Observer<ResponseBody> observer) { | 401 | public static void getChildrenList(Observer<ResponseBody> observer) { |
402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); | 402 | setSubscribe(service_url.getChildrenList(getHeader()), observer); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { | 406 | public static void registerParent(RequestBody body, Observer<ResponseBody> observer) { |
407 | setSubscribe(service_url.registerParent(body), observer); | 407 | setSubscribe(service_url.registerParent(body), observer); |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | public static void listChildren(Observer<ResponseBody> observer) { | 411 | public static void listChildren(Observer<ResponseBody> observer) { |
412 | setSubscribe(service_url.listChildren(getHeader()), observer); | 412 | setSubscribe(service_url.listChildren(getHeader()), observer); |
413 | } | 413 | } |
414 | 414 | ||
415 | public static void listStudent(Observer<ResponseBody> observer) { | 415 | public static void listStudent(Observer<ResponseBody> observer) { |
416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 416 | setSubscribe(service_url.getStudentList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
417 | } | 417 | } |
418 | 418 | ||
419 | public static Single<ResponseResult<List<Student>>> listStudent() { | 419 | public static Single<ResponseResult<List<Student>>> listStudent() { |
420 | return service_url.getStudentList2(getHeader(), getUserId()); | 420 | return service_url.getStudentList2(getHeader(), getUserId()); |
421 | } | 421 | } |
422 | 422 | ||
423 | public static void listRecord(Observer<ResponseBody> observer) { | 423 | public static void listRecord(Observer<ResponseBody> observer) { |
424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); | 424 | setSubscribe(service_url.getRecordList(getHeader(), (String) SharedPreferencesUtil.getData("userId", "")), observer); |
425 | } | 425 | } |
426 | 426 | ||
427 | 427 | ||
428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { | 428 | public static void registerStudent(RequestBody body, Observer<ResponseBody> observer) { |
429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); | 429 | setSubscribe(service_url.registerStudent(getHeader(), body), observer); |
430 | } | 430 | } |
431 | 431 | ||
432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { | 432 | public static void bindTeacher(RequestBody body, Observer<ResponseBody> observer) { |
433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); | 433 | setSubscribe(service_url.bindTeacher(getHeader(), body), observer); |
434 | } | 434 | } |
435 | 435 | ||
436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { | 436 | public static void getError(Map map, Observer<ResponseResult<PageInfo<TopicBean>>> observer) { |
437 | setSubscribe(service_url.getError(getHeader(), map), observer); | 437 | setSubscribe(service_url.getError(getHeader(), map), observer); |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | public static RequestBody getMapRequestBody(Map map) { | 441 | public static RequestBody getMapRequestBody(Map map) { |
442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | 442 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); |
443 | } | 443 | } |
444 | 444 | ||
445 | 445 | ||
446 | public static RequestBody getArrayRequestBody(List list) { | 446 | public static RequestBody getArrayRequestBody(List list) { |
447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | 447 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); |
448 | } | 448 | } |
449 | 449 | ||
450 | public static RequestBody getFileRequestBody(File file) { | 450 | public static RequestBody getFileRequestBody(File file) { |
451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | 451 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); |
452 | } | 452 | } |
453 | 453 | ||
454 | public static RequestBody getFileRequestBody(byte[] bytes) { | 454 | public static RequestBody getFileRequestBody(byte[] bytes) { |
455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | 455 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); |
456 | } | 456 | } |
457 | 457 | ||
458 | public static RequestBody getObjectRequestBody(Object obj) { | 458 | public static RequestBody getObjectRequestBody(Object obj) { |
459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | 459 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); |
460 | } | 460 | } |
461 | 461 | ||
462 | public static RequestBody getStringRequestBody(String str) { | 462 | public static RequestBody getStringRequestBody(String str) { |
463 | return RequestBody.create(MediaType.parse("text/plain"), str); | 463 | return RequestBody.create(MediaType.parse("text/plain"), str); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | /** | 467 | /** |
468 | * 插入观察者 | 468 | * 插入观察者 |
469 | * | 469 | * |
470 | * @param observable | 470 | * @param observable |
471 | * @param observer | 471 | * @param observer |
472 | * @param <T> | 472 | * @param <T> |
473 | */ | 473 | */ |
474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | 474 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { |
475 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | 475 | observable.subscribeOn(Schedulers.io())//子线程访问网络 |
476 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | 476 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 |
477 | .subscribe(observer); | 477 | .subscribe(observer); |
478 | } | 478 | } |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 |