Commit 7ba87854ba4831b6cbef7a3630a08e2d018c41fb
1 parent
508a582a75
Exists in
master
数据逻辑调整
Showing
1 changed file
with
3 additions
and
0 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.CorrectionPoint; | 22 | import com.prws.common.bean.homework.CorrectionPoint; |
| 23 | import com.prws.common.bean.homework.CorrectionSer; | 23 | import com.prws.common.bean.homework.CorrectionSer; |
| 24 | import com.prws.common.bean.homework.HomeWork; | 24 | import com.prws.common.bean.homework.HomeWork; |
| 25 | import com.prws.common.bean.homework.HomeworkList; | 25 | import com.prws.common.bean.homework.HomeworkList; |
| 26 | import com.prws.common.bean.homework.KeyValue; | 26 | import com.prws.common.bean.homework.KeyValue; |
| 27 | import com.prws.common.net.NetWorks; | 27 | import com.prws.common.net.NetWorks; |
| 28 | 28 | ||
| 29 | import java.text.DecimalFormat; | 29 | import java.text.DecimalFormat; |
| 30 | import java.text.SimpleDateFormat; | 30 | import java.text.SimpleDateFormat; |
| 31 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
| 32 | import java.util.HashMap; | 32 | import java.util.HashMap; |
| 33 | import java.util.HashSet; | 33 | import java.util.HashSet; |
| 34 | import java.util.List; | 34 | import java.util.List; |
| 35 | import java.util.Locale; | 35 | import java.util.Locale; |
| 36 | import java.util.Map; | 36 | import java.util.Map; |
| 37 | import java.util.Set; | 37 | import java.util.Set; |
| 38 | 38 | ||
| 39 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { | 39 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { |
| 40 | private Student student; | 40 | private Student student; |
| 41 | private HomeworkList mData; | 41 | private HomeworkList mData; |
| 42 | private ArrayList<HomeWork> mList; | 42 | private ArrayList<HomeWork> mList; |
| 43 | private List<CorrectionSer> corrections = new ArrayList<>(); | 43 | private List<CorrectionSer> corrections = new ArrayList<>(); |
| 44 | 44 | ||
| 45 | @SuppressWarnings("unchecked") | 45 | @SuppressWarnings("unchecked") |
| 46 | @Override | 46 | @Override |
| 47 | public void initView(Bundle savedInstanceState) { | 47 | public void initView(Bundle savedInstanceState) { |
| 48 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | 48 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); |
| 49 | student = (Student) getIntent().getSerializableExtra("student"); | 49 | student = (Student) getIntent().getSerializableExtra("student"); |
| 50 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); | 50 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); |
| 51 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | 51 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); |
| 52 | 52 | ||
| 53 | binding.tvStuName.setText(student.stuName); | 53 | binding.tvStuName.setText(student.stuName); |
| 54 | binding.tvGrade.setText(student.grade); | 54 | binding.tvGrade.setText(student.grade); |
| 55 | 55 | ||
| 56 | List<HomeWork> correctList = new ArrayList<>(); | 56 | List<HomeWork> correctList = new ArrayList<>(); |
| 57 | List<HomeWork> errorList = new ArrayList<>(); | 57 | List<HomeWork> errorList = new ArrayList<>(); |
| 58 | List<HomeWork> blankList = new ArrayList<>(); | 58 | List<HomeWork> blankList = new ArrayList<>(); |
| 59 | int correctNo = 0, blankNo = 0; | 59 | int correctNo = 0, blankNo = 0; |
| 60 | for (HomeWork homeWork: mList) { | 60 | for (HomeWork homeWork: mList) { |
| 61 | homeWork.state = 1; | 61 | homeWork.state = 1; |
| 62 | homeWork.index = mList.indexOf(homeWork); | 62 | homeWork.index = mList.indexOf(homeWork); |
| 63 | corrections.add(homeWork.toSer()); | 63 | corrections.add(homeWork.toSer()); |
| 64 | if (homeWork.correction == 0) { | 64 | if (homeWork.correction == 0) { |
| 65 | correctList.add(homeWork); | 65 | correctList.add(homeWork); |
| 66 | correctNo ++; | 66 | correctNo ++; |
| 67 | } | 67 | } |
| 68 | else if (homeWork.correction == 1) { | 68 | else if (homeWork.correction == 1) { |
| 69 | correctList.add(homeWork); | 69 | correctList.add(homeWork); |
| 70 | errorList.add(homeWork); | 70 | errorList.add(homeWork); |
| 71 | } | 71 | } |
| 72 | else if (homeWork.correction == 2) { | 72 | else if (homeWork.correction == 2) { |
| 73 | blankList.add(homeWork); | 73 | blankList.add(homeWork); |
| 74 | blankNo ++; | 74 | blankNo ++; |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | binding.viewBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); | 77 | binding.viewBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); |
| 78 | binding.rvBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); | 78 | binding.rvBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE); |
| 79 | 79 | ||
| 80 | float rate = 1f * correctNo / Math.max(mList.size() - blankNo, 1); | 80 | float rate = 1f * correctNo / Math.max(mList.size() - blankNo, 1); |
| 81 | binding.tvPercent.setText(new DecimalFormat("0%").format(rate)); | 81 | binding.tvPercent.setText(new DecimalFormat("0%").format(rate)); |
| 82 | 82 | ||
| 83 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); | 83 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); |
| 84 | binding.rvBlank.setLayoutManager(new FlexboxLayoutManager(this)); | 84 | binding.rvBlank.setLayoutManager(new FlexboxLayoutManager(this)); |
| 85 | NumberAdapter numberAdapter = new NumberAdapter(correctList); | 85 | NumberAdapter numberAdapter = new NumberAdapter(correctList); |
| 86 | NumberAdapter blankAdapter = new NumberAdapter(blankList); | 86 | NumberAdapter blankAdapter = new NumberAdapter(blankList); |
| 87 | binding.rvCorrect.setAdapter(numberAdapter); | 87 | binding.rvCorrect.setAdapter(numberAdapter); |
| 88 | binding.rvBlank.setAdapter(blankAdapter); | 88 | binding.rvBlank.setAdapter(blankAdapter); |
| 89 | 89 | ||
| 90 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); | 90 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); |
| 91 | binding.rvError.setAdapter(new EvalAdapter(errorList)); | 91 | binding.rvError.setAdapter(new EvalAdapter(errorList)); |
| 92 | if (errorList.isEmpty()) { | 92 | if (errorList.isEmpty()) { |
| 93 | binding.flEval.setVisibility(View.GONE); | 93 | binding.flEval.setVisibility(View.GONE); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | binding.btnDetail.setOnClickListener(v -> { | 96 | binding.btnDetail.setOnClickListener(v -> { |
| 97 | viewTopicDetail(0); | 97 | viewTopicDetail(0); |
| 98 | }); | 98 | }); |
| 99 | binding.btnDetail2.setOnClickListener(v -> { | 99 | binding.btnDetail2.setOnClickListener(v -> { |
| 100 | viewTopicDetail(0); | 100 | viewTopicDetail(0); |
| 101 | }); | 101 | }); |
| 102 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | 102 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { |
| 103 | viewTopicDetail(i); | 103 | viewTopicDetail(i); |
| 104 | }); | 104 | }); |
| 105 | blankAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | 105 | blankAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { |
| 106 | viewTopicDetail(i); | 106 | viewTopicDetail(i); |
| 107 | }); | 107 | }); |
| 108 | binding.btnPublish.setOnClickListener(v -> submit()); | 108 | binding.btnPublish.setOnClickListener(v -> submit()); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | private void viewTopicDetail(int position) { | 111 | private void viewTopicDetail(int position) { |
| 112 | Intent intent = new Intent(this, HomeworkTopicActivity.class); | 112 | Intent intent = new Intent(this, HomeworkTopicActivity.class); |
| 113 | intent.putExtra("list", mList); | 113 | intent.putExtra("list", mList); |
| 114 | intent.putExtra("position", position); | 114 | intent.putExtra("position", position); |
| 115 | startActivity(intent); | 115 | startActivity(intent); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | @SuppressLint("CheckResult") | 118 | @SuppressLint("CheckResult") |
| 119 | private void submit() { | 119 | private void submit() { |
| 120 | Map<String, Object> body = new HashMap<>(); | 120 | Map<String, Object> body = new HashMap<>(); |
| 121 | body.put("homeworkId", mData.getId()); | 121 | body.put("homeworkId", mData.getId()); |
| 122 | body.put("comment", binding.etComment.getText().toString()); | 122 | body.put("comment", binding.etComment.getText().toString()); |
| 123 | body.put("stuId", student.stuId); | 123 | body.put("stuId", student.stuId); |
| 124 | body.put("points", countPoint()); | 124 | body.put("points", countPoint()); |
| 125 | body.put("correctionList", corrections); | 125 | body.put("correctionList", corrections); |
| 126 | body.put("extra", buildExtra()); | 126 | body.put("extra", buildExtra()); |
| 127 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) | 127 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) |
| 128 | .compose(transformSingle()) | 128 | .compose(transformSingle()) |
| 129 | .subscribe((response, th) -> { | 129 | .subscribe((response, th) -> { |
| 130 | if (th != null) th.printStackTrace(); | 130 | if (th != null) th.printStackTrace(); |
| 131 | if (response != null && response.getSuccess()) { | 131 | if (response != null && response.getSuccess()) { |
| 132 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); | 132 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); |
| 133 | 133 | ||
| 134 | Intent intent = new Intent(this, HomeworkShareActivity.class); | 134 | Intent intent = new Intent(this, HomeworkShareActivity.class); |
| 135 | intent.putExtra("student", student); | 135 | intent.putExtra("student", student); |
| 136 | intent.putExtra("id", mData.getId()); | 136 | intent.putExtra("id", mData.getId()); |
| 137 | intent.putExtra("grade", mData.getGrade()); | 137 | intent.putExtra("grade", mData.getGrade()); |
| 138 | intent.putExtra("subject", mData.getSubject()); | 138 | intent.putExtra("subject", mData.getSubject()); |
| 139 | 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); |
| 140 | intent.putExtra("name", name); | 140 | intent.putExtra("name", name); |
| 141 | startActivity(intent); | 141 | startActivity(intent); |
| 142 | 142 | ||
| 143 | setResult(RESULT_OK); | 143 | setResult(RESULT_OK); |
| 144 | finish(); | 144 | finish(); |
| 145 | } else { | 145 | } else { |
| 146 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); | 146 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); |
| 147 | } | 147 | } |
| 148 | }); | 148 | }); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | private String buildExtra() { | 151 | private String buildExtra() { |
| 152 | if (mList == null || mList.isEmpty()) return null; | 152 | if (mList == null || mList.isEmpty()) return null; |
| 153 | List<CorrectionSer> maps = new ArrayList<>(); | 153 | List<CorrectionSer> maps = new ArrayList<>(); |
| 154 | for (HomeWork item: mList) { | 154 | for (HomeWork item: mList) { |
| 155 | if (item.correction == 2) continue; | ||
| 155 | maps.add(item.toSer()); | 156 | maps.add(item.toSer()); |
| 156 | } | 157 | } |
| 158 | if (maps.isEmpty()) return null; | ||
| 157 | Gson gson = new Gson(); | 159 | Gson gson = new Gson(); |
| 158 | return gson.toJson(maps); | 160 | return gson.toJson(maps); |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | @SuppressLint("CheckResult") | 163 | @SuppressLint("CheckResult") |
| 162 | private List<CorrectionPoint> countPoint() { | 164 | private List<CorrectionPoint> countPoint() { |
| 163 | Set<KeyValue> set = new HashSet<>(); | 165 | Set<KeyValue> set = new HashSet<>(); |
| 164 | Map<String, Integer> totalTimes = new HashMap<>(); | 166 | Map<String, Integer> totalTimes = new HashMap<>(); |
| 165 | Map<String, Integer> correctTimes = new HashMap<>(); | 167 | Map<String, Integer> correctTimes = new HashMap<>(); |
| 166 | Map<String, Integer> underTimes = new HashMap<>(); | 168 | Map<String, Integer> underTimes = new HashMap<>(); |
| 167 | Map<String, Integer> baseTimes = new HashMap<>(); | 169 | Map<String, Integer> baseTimes = new HashMap<>(); |
| 168 | Map<String, Integer> normalTimes = new HashMap<>(); | 170 | Map<String, Integer> normalTimes = new HashMap<>(); |
| 169 | Gson gson = new Gson(); | 171 | Gson gson = new Gson(); |
| 170 | for (HomeWork homeWork: mList) { | 172 | for (HomeWork homeWork: mList) { |
| 173 | if (homeWork.correction == 2) continue; | ||
| 171 | homeWork.formatPoints(gson); | 174 | homeWork.formatPoints(gson); |
| 172 | 175 | ||
| 173 | set.addAll(homeWork.pointsObj); | 176 | set.addAll(homeWork.pointsObj); |
| 174 | for (KeyValue keyValue: homeWork.pointsObj) { | 177 | for (KeyValue keyValue: homeWork.pointsObj) { |
| 175 | String key = keyValue.Key; | 178 | String key = keyValue.Key; |
| 176 | if (totalTimes.containsKey(key)) { | 179 | if (totalTimes.containsKey(key)) { |
| 177 | totalTimes.put(key, totalTimes.get(key) + 1); | 180 | totalTimes.put(key, totalTimes.get(key) + 1); |
| 178 | } else { | 181 | } else { |
| 179 | totalTimes.put(key, 1); | 182 | totalTimes.put(key, 1); |
| 180 | } | 183 | } |
| 181 | if (homeWork.correction == 0) { | 184 | if (homeWork.correction == 0) { |
| 182 | if (correctTimes.containsKey(key)) { | 185 | if (correctTimes.containsKey(key)) { |
| 183 | correctTimes.put(key, correctTimes.get(key) + 1); | 186 | correctTimes.put(key, correctTimes.get(key) + 1); |
| 184 | } else { | 187 | } else { |
| 185 | correctTimes.put(key, 1); | 188 | correctTimes.put(key, 1); |
| 186 | } | 189 | } |
| 187 | } else if (homeWork.correction == 1) { | 190 | } else if (homeWork.correction == 1) { |
| 188 | if (homeWork.state == 1) { | 191 | if (homeWork.state == 1) { |
| 189 | if (underTimes.containsKey(key)) { | 192 | if (underTimes.containsKey(key)) { |
| 190 | underTimes.put(key, underTimes.get(key) + 1); | 193 | underTimes.put(key, underTimes.get(key) + 1); |
| 191 | } else { | 194 | } else { |
| 192 | underTimes.put(key, 1); | 195 | underTimes.put(key, 1); |
| 193 | } | 196 | } |
| 194 | } else if (homeWork.state == 2) { | 197 | } else if (homeWork.state == 2) { |
| 195 | if (baseTimes.containsKey(key)) { | 198 | if (baseTimes.containsKey(key)) { |
| 196 | baseTimes.put(key, baseTimes.get(key) + 1); | 199 | baseTimes.put(key, baseTimes.get(key) + 1); |
| 197 | } else { | 200 | } else { |
| 198 | baseTimes.put(key, 1); | 201 | baseTimes.put(key, 1); |
| 199 | } | 202 | } |
| 200 | } else if (homeWork.state == 3) { | 203 | } else if (homeWork.state == 3) { |
| 201 | if (normalTimes.containsKey(key)) { | 204 | if (normalTimes.containsKey(key)) { |
| 202 | normalTimes.put(key, normalTimes.get(key) + 1); | 205 | normalTimes.put(key, normalTimes.get(key) + 1); |
| 203 | } else { | 206 | } else { |
| 204 | normalTimes.put(key, 1); | 207 | normalTimes.put(key, 1); |
| 205 | } | 208 | } |
| 206 | } | 209 | } |
| 207 | } | 210 | } |
| 208 | } | 211 | } |
| 209 | } | 212 | } |
| 210 | List<CorrectionPoint> points = new ArrayList<>(); | 213 | List<CorrectionPoint> points = new ArrayList<>(); |
| 211 | for (KeyValue obj: set) { | 214 | for (KeyValue obj: set) { |
| 212 | CorrectionPoint point = new CorrectionPoint(); | 215 | CorrectionPoint point = new CorrectionPoint(); |
| 213 | point.pointId = obj.Key; | 216 | point.pointId = obj.Key; |
| 214 | point.pointName = obj.Value; | 217 | point.pointName = obj.Value; |
| 215 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); | 218 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); |
| 216 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); | 219 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); |
| 217 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); | 220 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); |
| 218 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); | 221 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); |
| 219 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); | 222 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); |
| 220 | 223 | ||
| 221 | points.add(point); | 224 | points.add(point); |
| 222 | } | 225 | } |
| 223 | 226 | ||
| 224 | return points; | 227 | return points; |
| 225 | } | 228 | } |
| 226 | 229 | ||
| 227 | private int ifNull(Integer src, int defaultVal) { | 230 | private int ifNull(Integer src, int defaultVal) { |
| 228 | if (src == null) return defaultVal; | 231 | if (src == null) return defaultVal; |
| 229 | else return src; | 232 | else return src; |
| 230 | } | 233 | } |
| 231 | 234 | ||
| 232 | 235 | ||
| 233 | @Override | 236 | @Override |
| 234 | protected ActivityHomeworkFeedbackBinding getViewBinding() { | 237 | protected ActivityHomeworkFeedbackBinding getViewBinding() { |
| 235 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); | 238 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); |
| 236 | } | 239 | } |
| 237 | 240 | ||
| 238 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 241 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
| 239 | 242 | ||
| 240 | public NumberAdapter(List<HomeWork> list) { | 243 | public NumberAdapter(List<HomeWork> list) { |
| 241 | super(R.layout.item_feedback_num, list); | 244 | super(R.layout.item_feedback_num, list); |
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | @Override | 247 | @Override |
| 245 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 248 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
| 246 | int position = getData().indexOf(homeWork); | 249 | int position = getData().indexOf(homeWork); |
| 247 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); | 250 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); |
| 248 | if (homeWork.correction == 1) { | 251 | if (homeWork.correction == 1) { |
| 249 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); | 252 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); |
| 250 | } else if (homeWork.correction == 0){ | 253 | } else if (homeWork.correction == 0){ |
| 251 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); | 254 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); |
| 252 | } else { | 255 | } else { |
| 253 | holder.setImageDrawable(R.id.ivType, null); | 256 | holder.setImageDrawable(R.id.ivType, null); |
| 254 | } | 257 | } |
| 255 | } | 258 | } |
| 256 | } | 259 | } |
| 257 | 260 | ||
| 258 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 261 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
| 259 | 262 | ||
| 260 | public EvalAdapter(@Nullable List<HomeWork> data) { | 263 | public EvalAdapter(@Nullable List<HomeWork> data) { |
| 261 | super(R.layout.item_homework_eval, data); | 264 | super(R.layout.item_homework_eval, data); |
| 262 | } | 265 | } |
| 263 | 266 | ||
| 264 | @Override | 267 | @Override |
| 265 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 268 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
| 266 | holder.itemView.setClipToOutline(true); | 269 | holder.itemView.setClipToOutline(true); |
| 267 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); | 270 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); |
| 268 | ImageView iv = holder.getView(R.id.ivTopic); | 271 | ImageView iv = holder.getView(R.id.ivTopic); |
| 269 | Glide.with(mContext).load(homeWork.url).into(iv); | 272 | Glide.with(mContext).load(homeWork.url).into(iv); |
| 270 | 273 | ||
| 271 | RadioButton chk1 = holder.getView(R.id.chk1); | 274 | RadioButton chk1 = holder.getView(R.id.chk1); |
| 272 | RadioButton chk2 = holder.getView(R.id.chk2); | 275 | RadioButton chk2 = holder.getView(R.id.chk2); |
| 273 | RadioButton chk3 = holder.getView(R.id.chk3); | 276 | RadioButton chk3 = holder.getView(R.id.chk3); |
| 274 | chk1.setOnCheckedChangeListener((v, b) -> { | 277 | chk1.setOnCheckedChangeListener((v, b) -> { |
| 275 | if (b) { | 278 | if (b) { |
| 276 | homeWork.state = 1; | 279 | homeWork.state = 1; |
| 277 | } | 280 | } |
| 278 | }); | 281 | }); |
| 279 | chk2.setOnCheckedChangeListener((v, b) -> { | 282 | chk2.setOnCheckedChangeListener((v, b) -> { |
| 280 | if (b) { | 283 | if (b) { |
| 281 | homeWork.state = 2; | 284 | homeWork.state = 2; |
| 282 | } | 285 | } |
| 283 | }); | 286 | }); |
| 284 | chk3.setOnCheckedChangeListener((v, b) -> { | 287 | chk3.setOnCheckedChangeListener((v, b) -> { |
| 285 | if (b) { | 288 | if (b) { |
| 286 | homeWork.state = 3; | 289 | homeWork.state = 3; |
| 287 | } | 290 | } |
| 288 | }); | 291 | }); |
| 289 | chk1.setChecked(homeWork.state == 1); | 292 | chk1.setChecked(homeWork.state == 1); |
| 290 | chk2.setChecked(homeWork.state == 2); | 293 | chk2.setChecked(homeWork.state == 2); |
| 291 | chk3.setChecked(homeWork.state == 3); | 294 | chk3.setChecked(homeWork.state == 3); |
| 292 | } | 295 | } |
| 293 | } | 296 | } |
| 294 | } | 297 | } |
| 295 | 298 |