Commit 7eb90a5ec115687f5f075028b3dc19d1ec54bda7
1 parent
b49795b72f
Exists in
master
作业反馈
Showing
13 changed files
with
260 additions
and
2 deletions
Show diff stats
app/build.gradle
app/src/main/java/com/hjx/parent/HomeworkFeedbackActivity.java
1 | 1 | package com.hjx.parent; |
2 | 2 | |
3 | 3 | import android.os.Bundle; |
4 | +import android.view.View; | |
5 | +import android.widget.ImageView; | |
6 | +import android.widget.RadioButton; | |
4 | 7 | |
8 | +import androidx.annotation.NonNull; | |
9 | +import androidx.annotation.Nullable; | |
10 | + | |
11 | +import com.bumptech.glide.Glide; | |
12 | +import com.chad.library.adapter.base.BaseQuickAdapter; | |
13 | +import com.chad.library.adapter.base.BaseViewHolder; | |
14 | +import com.google.android.flexbox.FlexboxLayoutManager; | |
5 | 15 | import com.hjx.parent.databinding.ActivityHomeworkFeedbackBinding; |
6 | 16 | import com.hjx.parent.rx.BaseRxActivity; |
7 | 17 | import com.prws.common.bean.Student; |
... | ... | @@ -10,6 +20,7 @@ import com.prws.common.bean.homework.HomeworkList; |
10 | 20 | |
11 | 21 | import java.text.DecimalFormat; |
12 | 22 | import java.util.ArrayList; |
23 | +import java.util.List; | |
13 | 24 | |
14 | 25 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { |
15 | 26 | private Student student; |
... | ... | @@ -27,16 +38,78 @@ public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFee |
27 | 38 | binding.tvStuName.setText(student.stuName); |
28 | 39 | binding.tvGrade.setText(student.grade); |
29 | 40 | |
41 | + List<HomeWork> errorList = new ArrayList<>(); | |
30 | 42 | int correctNo = 0; |
31 | 43 | for (HomeWork homeWork: mList) { |
32 | 44 | homeWork.homeworkId = mData.getId(); |
33 | 45 | if (!homeWork.check) correctNo ++; |
46 | + else errorList.add(homeWork); | |
34 | 47 | } |
35 | 48 | binding.tvPercent.setText(new DecimalFormat("0%").format(1f * correctNo / mList.size())); |
49 | + | |
50 | + binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); | |
51 | + binding.rvCorrect.setAdapter(new NumberAdapter(mList)); | |
52 | + binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); | |
53 | + binding.rvError.setAdapter(new EvalAdapter(errorList)); | |
36 | 54 | } |
37 | 55 | |
38 | 56 | @Override |
39 | 57 | protected ActivityHomeworkFeedbackBinding getViewBinding() { |
40 | 58 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); |
41 | 59 | } |
60 | + | |
61 | + static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | |
62 | + | |
63 | + public NumberAdapter(List<HomeWork> list) { | |
64 | + super(R.layout.item_feedback_num, list); | |
65 | + } | |
66 | + | |
67 | + @Override | |
68 | + protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | |
69 | + int position = getData().indexOf(homeWork); | |
70 | + holder.setText(R.id.tvNum, String.valueOf(position + 1)); | |
71 | + if (homeWork.check) { | |
72 | + holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); | |
73 | + } else { | |
74 | + holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); | |
75 | + } | |
76 | + } | |
77 | + } | |
78 | + | |
79 | + static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | |
80 | + | |
81 | + public EvalAdapter(@Nullable List<HomeWork> data) { | |
82 | + super(R.layout.item_homework_eval, data); | |
83 | + } | |
84 | + | |
85 | + @Override | |
86 | + protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | |
87 | + holder.itemView.setClipToOutline(true); | |
88 | + holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); | |
89 | + ImageView iv = holder.getView(R.id.ivTopic); | |
90 | + Glide.with(mContext).load(homeWork.url).into(iv); | |
91 | + | |
92 | + RadioButton chk1 = holder.getView(R.id.chk1); | |
93 | + RadioButton chk2 = holder.getView(R.id.chk2); | |
94 | + RadioButton chk3 = holder.getView(R.id.chk3); | |
95 | + chk1.setOnCheckedChangeListener((v, b) -> { | |
96 | + if (b) { | |
97 | + homeWork.state = 1; | |
98 | + } | |
99 | + }); | |
100 | + chk2.setOnCheckedChangeListener((v, b) -> { | |
101 | + if (b) { | |
102 | + homeWork.state = 2; | |
103 | + } | |
104 | + }); | |
105 | + chk3.setOnCheckedChangeListener((v, b) -> { | |
106 | + if (b) { | |
107 | + homeWork.state = 3; | |
108 | + } | |
109 | + }); | |
110 | + chk1.setChecked(homeWork.state == 1); | |
111 | + chk2.setChecked(homeWork.state == 2); | |
112 | + chk3.setChecked(homeWork.state == 3); | |
113 | + } | |
114 | + } | |
42 | 115 | } | ... | ... |
app/src/main/res/drawable/bg_homework_eval_item.xml
app/src/main/res/drawable/bg_homework_num.xml
app/src/main/res/drawable/btn_homework_eval1.xml
... | ... | @@ -0,0 +1,18 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + <item android:state_checked="true"> | |
5 | + <shape> | |
6 | + <corners android:radius="888dp"/> | |
7 | + <solid android:color="#489AFA"/> | |
8 | + </shape> | |
9 | + </item> | |
10 | + | |
11 | + <item> | |
12 | + <shape> | |
13 | + <corners android:radius="888dp"/> | |
14 | + <solid android:color="#DCDCDC"/> | |
15 | + </shape> | |
16 | + </item> | |
17 | + | |
18 | +</selector> | |
0 | 19 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/btn_homework_eval2.xml
... | ... | @@ -0,0 +1,18 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + <item android:state_checked="true"> | |
5 | + <shape> | |
6 | + <corners android:radius="888dp"/> | |
7 | + <solid android:color="#FF7E00"/> | |
8 | + </shape> | |
9 | + </item> | |
10 | + | |
11 | + <item> | |
12 | + <shape> | |
13 | + <corners android:radius="888dp"/> | |
14 | + <solid android:color="#DCDCDC"/> | |
15 | + </shape> | |
16 | + </item> | |
17 | + | |
18 | +</selector> | |
0 | 19 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/btn_homework_eval3.xml
... | ... | @@ -0,0 +1,18 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + <item android:state_checked="true"> | |
5 | + <shape> | |
6 | + <corners android:radius="888dp"/> | |
7 | + <solid android:color="#FF4133"/> | |
8 | + </shape> | |
9 | + </item> | |
10 | + | |
11 | + <item> | |
12 | + <shape> | |
13 | + <corners android:radius="888dp"/> | |
14 | + <solid android:color="#DCDCDC"/> | |
15 | + </shape> | |
16 | + </item> | |
17 | + | |
18 | +</selector> | |
0 | 19 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/ic_correct_small.png
1.31 KB
app/src/main/res/drawable/ic_wrong_small.png
1.29 KB
app/src/main/res/layout/activity_homework_feedback.xml
... | ... | @@ -160,6 +160,7 @@ |
160 | 160 | |
161 | 161 | <androidx.recyclerview.widget.RecyclerView |
162 | 162 | android:id="@+id/rvCorrect" |
163 | + tools:listitem="@layout/item_feedback_num" | |
163 | 164 | tools:itemCount="1" |
164 | 165 | android:layout_marginTop="15dp" |
165 | 166 | android:layout_marginHorizontal="15dp" |
... | ... | @@ -169,13 +170,13 @@ |
169 | 170 | android:text="错题已经加入到错题本,到错题本查看详情" |
170 | 171 | android:textSize="12sp" |
171 | 172 | android:textColor="#666" |
172 | - android:layout_marginTop="15dp" | |
173 | 173 | android:layout_marginHorizontal="15dp" |
174 | 174 | android:layout_width="wrap_content" |
175 | 175 | android:layout_height="wrap_content"/> |
176 | 176 | </LinearLayout> |
177 | 177 | |
178 | 178 | <LinearLayout |
179 | + android:id="@+id/flEval" | |
179 | 180 | android:orientation="vertical" |
180 | 181 | android:background="@drawable/shape_radius_10" |
181 | 182 | android:backgroundTint="@color/white" |
... | ... | @@ -183,7 +184,7 @@ |
183 | 184 | android:layout_width="match_parent" |
184 | 185 | android:layout_height="wrap_content"> |
185 | 186 | <androidx.appcompat.widget.AppCompatTextView |
186 | - android:text="作业详情" | |
187 | + android:text="辅导后错题掌握评估" | |
187 | 188 | android:textSize="16sp" |
188 | 189 | android:textColor="#333" |
189 | 190 | android:textStyle="bold" | ... | ... |
app/src/main/res/layout/item_feedback_num.xml
... | ... | @@ -0,0 +1,22 @@ |
1 | +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | + android:layout_width="28dp" | |
3 | + android:layout_height="28dp" | |
4 | + android:layout_marginBottom="10dp" | |
5 | + android:layout_marginEnd="20dp"> | |
6 | + | |
7 | + <TextView | |
8 | + android:id="@+id/tvNum" | |
9 | + android:layout_width="25dp" | |
10 | + android:layout_height="25dp" | |
11 | + android:background="@drawable/shape_radius_5" | |
12 | + android:backgroundTint="#D7EBFF" | |
13 | + android:gravity="center" | |
14 | + android:textColor="#4D9CF7" | |
15 | + android:textSize="18sp" /> | |
16 | + | |
17 | + <ImageView | |
18 | + android:id="@+id/ivType" | |
19 | + android:layout_width="12dp" | |
20 | + android:layout_height="12dp" | |
21 | + android:layout_gravity="end|bottom"/> | |
22 | +</FrameLayout> | |
0 | 23 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item_homework_eval.xml
... | ... | @@ -0,0 +1,93 @@ |
1 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
3 | + xmlns:tools="http://schemas.android.com/tools" | |
4 | + android:orientation="vertical" | |
5 | + tools:layout_width="280dp" | |
6 | + android:layout_width="match_parent" | |
7 | + android:layout_height="wrap_content" | |
8 | + android:layout_marginHorizontal="16dp" | |
9 | + android:layout_marginTop="16dp" | |
10 | + android:background="@drawable/bg_homework_eval_item" | |
11 | + tools:ignore="HardcodedText,SmallSp"> | |
12 | + | |
13 | + <FrameLayout | |
14 | + android:layout_width="match_parent" | |
15 | + android:layout_height="110dp"> | |
16 | + | |
17 | + <androidx.constraintlayout.utils.widget.ImageFilterView | |
18 | + android:id="@+id/ivTopic" | |
19 | + app:round="10dp" | |
20 | + android:layout_margin="1dp" | |
21 | + android:layout_width="match_parent" | |
22 | + android:layout_height="match_parent" /> | |
23 | + | |
24 | + <TextView | |
25 | + android:id="@+id/tvNo" | |
26 | + tools:text="题目8" | |
27 | + android:layout_width="40dp" | |
28 | + android:layout_height="16dp" | |
29 | + android:layout_gravity="end" | |
30 | + android:background="@drawable/bg_homework_num" | |
31 | + android:gravity="center" | |
32 | + android:textColor="@color/white" | |
33 | + android:textSize="9sp" /> | |
34 | + </FrameLayout> | |
35 | + | |
36 | + <View | |
37 | + android:background="#EEEEEE" | |
38 | + android:layout_width="match_parent" | |
39 | + android:layout_height="1dp"/> | |
40 | + | |
41 | + <RadioGroup | |
42 | + android:id="@+id/chkGroup" | |
43 | + android:orientation="horizontal" | |
44 | + android:gravity="center_vertical" | |
45 | + android:paddingHorizontal="10dp" | |
46 | + android:layout_width="match_parent" | |
47 | + android:layout_height="46dp"> | |
48 | + | |
49 | + <RadioButton | |
50 | + android:id="@+id/chk1" | |
51 | + android:text="已听懂" | |
52 | + android:textSize="12sp" | |
53 | + android:textColor="@color/white" | |
54 | + android:gravity="center" | |
55 | + android:button="@null" | |
56 | + tools:checked="true" | |
57 | + android:background="@drawable/btn_homework_eval1" | |
58 | + android:layout_marginHorizontal="10dp" | |
59 | + android:layout_weight="1" | |
60 | + android:layout_width="0dp" | |
61 | + android:layout_height="25dp" /> | |
62 | + | |
63 | + <RadioButton | |
64 | + android:id="@+id/chk2" | |
65 | + android:text="基本听懂" | |
66 | + android:textSize="12sp" | |
67 | + android:textColor="@color/white" | |
68 | + android:gravity="center" | |
69 | + android:button="@null" | |
70 | + tools:checked="true" | |
71 | + android:background="@drawable/btn_homework_eval2" | |
72 | + android:layout_marginHorizontal="10dp" | |
73 | + android:layout_weight="1" | |
74 | + android:layout_width="0dp" | |
75 | + android:layout_height="25dp" /> | |
76 | + | |
77 | + <RadioButton | |
78 | + android:id="@+id/chk3" | |
79 | + android:text="一般听懂" | |
80 | + android:textSize="12sp" | |
81 | + android:textColor="@color/white" | |
82 | + android:gravity="center" | |
83 | + android:button="@null" | |
84 | + tools:checked="true" | |
85 | + android:background="@drawable/btn_homework_eval3" | |
86 | + android:layout_marginHorizontal="10dp" | |
87 | + android:layout_weight="1" | |
88 | + android:layout_width="0dp" | |
89 | + android:layout_height="25dp" /> | |
90 | + | |
91 | + </RadioGroup> | |
92 | + | |
93 | +</LinearLayout> | |
0 | 94 | \ No newline at end of file | ... | ... |
libs/common/src/main/java/com/prws/common/bean/homework/HomeWork.java