Commit 68243277764608eac4dbc5f8544ec6f4607a3e7c
1 parent
eed2f75b0e
Exists in
master
数据错误修改
Showing
2 changed files
with
2 additions
and
15 deletions
Show diff stats
.idea/deploymentTargetDropDown.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="deploymentTargetDropDown"> | 3 | <component name="deploymentTargetDropDown"> |
4 | <value> | 4 | <value> |
5 | <entry key="app"> | 5 | <entry key="app"> |
6 | <State> | 6 | <State /> |
7 | <runningDeviceTargetSelectedWithDropDown> | ||
8 | <Target> | ||
9 | <type value="RUNNING_DEVICE_TARGET" /> | ||
10 | <deviceKey> | ||
11 | <Key> | ||
12 | <type value="SERIAL_NUMBER" /> | ||
13 | <value value="951f9ace" /> | ||
14 | </Key> | ||
15 | </deviceKey> | ||
16 | </Target> | ||
17 | </runningDeviceTargetSelectedWithDropDown> | ||
18 | <timeTargetWasSelectedWithDropDown value="2025-03-20T09:48:34.278363400Z" /> | ||
19 | </State> | ||
20 | </entry> | 7 | </entry> |
21 | </value> | 8 | </value> |
22 | </component> | 9 | </component> |
23 | </project> | 10 | </project> |
app/src/main/java/com/hjx/parent/HuyouDetailActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | 3 | ||
4 | import android.annotation.SuppressLint; | 4 | import android.annotation.SuppressLint; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.content.res.ColorStateList; | 6 | import android.content.res.ColorStateList; |
7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
8 | import android.net.Uri; | 8 | import android.net.Uri; |
9 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | import android.text.Html; | 10 | import android.text.Html; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | import android.widget.TextView; | 12 | import android.widget.TextView; |
13 | 13 | ||
14 | import androidx.annotation.NonNull; | 14 | import androidx.annotation.NonNull; |
15 | import androidx.annotation.Nullable; | 15 | import androidx.annotation.Nullable; |
16 | import androidx.core.content.res.ResourcesCompat; | 16 | import androidx.core.content.res.ResourcesCompat; |
17 | 17 | ||
18 | import com.bumptech.glide.Glide; | 18 | import com.bumptech.glide.Glide; |
19 | import com.chad.library.adapter.base.BaseQuickAdapter; | 19 | import com.chad.library.adapter.base.BaseQuickAdapter; |
20 | import com.chad.library.adapter.base.BaseViewHolder; | 20 | import com.chad.library.adapter.base.BaseViewHolder; |
21 | import com.github.mikephil.charting.components.Legend; | 21 | import com.github.mikephil.charting.components.Legend; |
22 | import com.github.mikephil.charting.components.XAxis; | 22 | import com.github.mikephil.charting.components.XAxis; |
23 | import com.github.mikephil.charting.components.YAxis; | 23 | import com.github.mikephil.charting.components.YAxis; |
24 | import com.github.mikephil.charting.data.Entry; | 24 | import com.github.mikephil.charting.data.Entry; |
25 | import com.github.mikephil.charting.data.LineData; | 25 | import com.github.mikephil.charting.data.LineData; |
26 | import com.github.mikephil.charting.data.LineDataSet; | 26 | import com.github.mikephil.charting.data.LineDataSet; |
27 | import com.github.mikephil.charting.formatter.ValueFormatter; | 27 | import com.github.mikephil.charting.formatter.ValueFormatter; |
28 | import com.gyf.immersionbar.ImmersionBar; | 28 | import com.gyf.immersionbar.ImmersionBar; |
29 | import com.hjx.parent.databinding.ActivityHuyouDetailBinding; | 29 | import com.hjx.parent.databinding.ActivityHuyouDetailBinding; |
30 | import com.hjx.parent.rx.BaseRxActivity; | 30 | import com.hjx.parent.rx.BaseRxActivity; |
31 | import com.prws.common.bean.Student; | 31 | import com.prws.common.bean.Student; |
32 | import com.prws.common.bean.homework.StDetail; | 32 | import com.prws.common.bean.homework.StDetail; |
33 | import com.prws.common.net.NetWorks; | 33 | import com.prws.common.net.NetWorks; |
34 | import com.prws.common.utils.BitmapUtils; | 34 | import com.prws.common.utils.BitmapUtils; |
35 | import com.prws.common.utils.ContentUtil; | 35 | import com.prws.common.utils.ContentUtil; |
36 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 36 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
37 | 37 | ||
38 | import java.text.DecimalFormat; | 38 | import java.text.DecimalFormat; |
39 | import java.text.SimpleDateFormat; | 39 | import java.text.SimpleDateFormat; |
40 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
41 | import java.util.Date; | 41 | import java.util.Date; |
42 | import java.util.List; | 42 | import java.util.List; |
43 | import java.util.Locale; | 43 | import java.util.Locale; |
44 | import java.util.TimeZone; | 44 | import java.util.TimeZone; |
45 | 45 | ||
46 | import io.reactivex.android.schedulers.AndroidSchedulers; | 46 | import io.reactivex.android.schedulers.AndroidSchedulers; |
47 | import io.reactivex.schedulers.Schedulers; | 47 | import io.reactivex.schedulers.Schedulers; |
48 | 48 | ||
49 | public class HuyouDetailActivity extends BaseRxActivity<ActivityHuyouDetailBinding> { | 49 | public class HuyouDetailActivity extends BaseRxActivity<ActivityHuyouDetailBinding> { |
50 | 50 | ||
51 | private String id; | 51 | private String id; |
52 | private int type; // 0:周 1:阶段 | 52 | private int type; // 0:周 1:阶段 |
53 | private Student student; | 53 | private Student student; |
54 | 54 | ||
55 | private StDetail mData; | 55 | private StDetail mData; |
56 | 56 | ||
57 | final String indent = " "; | 57 | final String indent = " "; |
58 | 58 | ||
59 | private boolean a4 = false; | 59 | private boolean a4 = false; |
60 | 60 | ||
61 | @Override | 61 | @Override |
62 | protected void onResume() { | 62 | protected void onResume() { |
63 | super.onResume(); | 63 | super.onResume(); |
64 | binding.root.postDelayed(() -> { | 64 | binding.root.postDelayed(() -> { |
65 | float scale = 1f * binding.getRoot().getWidth() / binding.root.getWidth(); | 65 | float scale = 1f * binding.getRoot().getWidth() / binding.root.getWidth(); |
66 | if (scale >= 1) return; | 66 | if (scale >= 1) return; |
67 | binding.root.setScaleX(scale); | 67 | binding.root.setScaleX(scale); |
68 | binding.root.setScaleY(scale); | 68 | binding.root.setScaleY(scale); |
69 | }, 100); | 69 | }, 100); |
70 | } | 70 | } |
71 | 71 | ||
72 | @SuppressLint("CheckResult") | 72 | @SuppressLint("CheckResult") |
73 | @Override | 73 | @Override |
74 | public void initView(Bundle savedInstanceState) { | 74 | public void initView(Bundle savedInstanceState) { |
75 | binding.btnBack.setOnClickListener(v -> onBackPressed()); | 75 | binding.btnBack.setOnClickListener(v -> onBackPressed()); |
76 | id = getIntent().getStringExtra("id"); | 76 | id = getIntent().getStringExtra("id"); |
77 | type = getIntent().getIntExtra("type", 0); | 77 | type = getIntent().getIntExtra("type", 0); |
78 | student = (Student) getIntent().getSerializableExtra("student"); | 78 | student = (Student) getIntent().getSerializableExtra("student"); |
79 | 79 | ||
80 | if (type == 1) { | 80 | if (type == 1) { |
81 | binding.tvTitle.setText("阶段作业学习总结"); | 81 | binding.tvTitle.setText("阶段作业学习总结"); |
82 | binding.viewWeekTable.setVisibility(View.GONE); | 82 | binding.viewWeekTable.setVisibility(View.GONE); |
83 | } else { | 83 | } else { |
84 | binding.viewPointTotal.setVisibility(View.GONE); | 84 | binding.viewPointTotal.setVisibility(View.GONE); |
85 | binding.viewTable.setVisibility(View.GONE); | 85 | binding.viewTable.setVisibility(View.GONE); |
86 | } | 86 | } |
87 | 87 | ||
88 | Glide.with(this).load(student.photo).into(binding.ivAvatar); | 88 | Glide.with(this).load(student.photo).into(binding.ivAvatar); |
89 | binding.tvStuName.setText(student.stuName); | 89 | binding.tvStuName.setText(student.stuName); |
90 | 90 | ||
91 | setupChart(); | 91 | setupChart(); |
92 | NetWorks.service_url.getHuyouDetail(NetWorks.getHeader(), id) | 92 | NetWorks.service_url.getHuyouDetail(NetWorks.getHeader(), id) |
93 | .subscribeOn(Schedulers.io()) | 93 | .subscribeOn(Schedulers.io()) |
94 | .map(response -> response.getData()) | 94 | .map(response -> response.getData()) |
95 | .map(data -> { | 95 | .map(data -> { |
96 | if (type == 1) data.formatCollection(); | 96 | if (type == 1) data.formatCollection(); |
97 | return data; | 97 | return data; |
98 | }) | 98 | }) |
99 | .observeOn(AndroidSchedulers.mainThread()) | 99 | .observeOn(AndroidSchedulers.mainThread()) |
100 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | 100 | .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) |
101 | .subscribe((data, th) -> { | 101 | .subscribe((data, th) -> { |
102 | mData = data; | 102 | mData = data; |
103 | if (th != null) th.printStackTrace(); | 103 | if (th != null) th.printStackTrace(); |
104 | if (data != null) showData(data); | 104 | if (data != null) showData(data); |
105 | }); | 105 | }); |
106 | 106 | ||
107 | binding.btnShare.setOnClickListener(v -> { | 107 | binding.btnShare.setOnClickListener(v -> { |
108 | Uri shareUri = prepareShare(); | 108 | Uri shareUri = prepareShare(); |
109 | if (shareUri != null) { | 109 | if (shareUri != null) { |
110 | Intent shareIntent = new Intent(Intent.ACTION_SEND); | 110 | Intent shareIntent = new Intent(Intent.ACTION_SEND); |
111 | shareIntent.setType("image/jpeg"); | 111 | shareIntent.setType("image/jpeg"); |
112 | shareIntent.putExtra(Intent.EXTRA_STREAM, shareUri); | 112 | shareIntent.putExtra(Intent.EXTRA_STREAM, shareUri); |
113 | shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 113 | shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
114 | 114 | ||
115 | startActivity(shareIntent); | 115 | startActivity(shareIntent); |
116 | } | 116 | } |
117 | }); | 117 | }); |
118 | 118 | ||
119 | binding.btnSwitch.setOnClickListener(v -> { | 119 | binding.btnSwitch.setOnClickListener(v -> { |
120 | switchPage(); | 120 | switchPage(); |
121 | }); | 121 | }); |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | private SimpleDateFormat getFormatWithGmt8(String pattern) { | 125 | private SimpleDateFormat getFormatWithGmt8(String pattern) { |
126 | SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA); | 126 | SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA); |
127 | format.setTimeZone(TimeZone.getTimeZone("GMT+16")); | 127 | format.setTimeZone(TimeZone.getTimeZone("GMT+16")); |
128 | return format; | 128 | return format; |
129 | } | 129 | } |
130 | 130 | ||
131 | @SuppressLint("SetTextI18n") | 131 | @SuppressLint("SetTextI18n") |
132 | private void showData(StDetail data) { | 132 | private void showData(StDetail data) { |
133 | binding.tvGrade.setText(data.grade); | 133 | binding.tvGrade.setText(data.grade); |
134 | binding.tvSubject.setText(data.homeworkSubject); | 134 | binding.tvSubject.setText(data.homeworkSubject); |
135 | String start = getFormatWithGmt8("yyyy.M.d").format(data.startTime); | 135 | String start = getFormatWithGmt8("yyyy.M.d").format(data.startTime); |
136 | String end = new SimpleDateFormat(" - M.d", Locale.CHINA).format(data.endTime); | 136 | String end = new SimpleDateFormat(" - M.d", Locale.CHINA).format(data.endTime); |
137 | binding.tvDate.setText(start + end); | 137 | binding.tvDate.setText(start + end); |
138 | 138 | ||
139 | if (data.points == null) data.points = new ArrayList<>(); | 139 | if (data.points == null) data.points = new ArrayList<>(); |
140 | if (data.points.size() == 0) { | 140 | if (data.points.size() == 0) { |
141 | binding.cpBefore.setValue(0); | 141 | binding.cpBefore.setValue(0); |
142 | binding.cpAfter.setValue(0); | 142 | binding.cpAfter.setValue(0); |
143 | binding.pgBefore.setText("0"); | 143 | binding.pgBefore.setText("0"); |
144 | binding.pgAfter.setText("0"); | 144 | binding.pgAfter.setText("0"); |
145 | } else { | 145 | } else { |
146 | float before = 0; | 146 | float before = 0; |
147 | float after = 0; | 147 | float after = 0; |
148 | for (StDetail.Point point: data.points) { | 148 | for (StDetail.Point point: data.points) { |
149 | before += point.beforeState; | 149 | before += point.beforeState; |
150 | after += point.afterState; | 150 | after += point.afterState; |
151 | } | 151 | } |
152 | before = (int) (100f * before / data.points.size() + 0.5f); | 152 | before = (int) (100f * before / data.points.size() + 0.5f); |
153 | after = (int) (100f * after / data.points.size() + 0.5f); | 153 | after = (int) (100f * after / data.points.size() + 0.5f); |
154 | binding.cpBefore.setValue(before); | 154 | binding.cpBefore.setValue(before); |
155 | binding.cpAfter.setValue(after); | 155 | binding.cpAfter.setValue(after); |
156 | DecimalFormat format = new DecimalFormat("0"); | 156 | DecimalFormat format = new DecimalFormat("0"); |
157 | binding.pgBefore.setText(format.format(before)); | 157 | binding.pgBefore.setText(format.format(before)); |
158 | binding.pgAfter.setText(format.format(after)); | 158 | binding.pgAfter.setText(format.format(after)); |
159 | 159 | ||
160 | String comment; | 160 | String comment; |
161 | if (after >= 90) { | 161 | if (after >= 90) { |
162 | comment = "知识点掌握的比较扎实,多练习多巩固掌握一般的知识点会有很大帮助。"; | 162 | comment = "知识点掌握的比较扎实,多练习多巩固掌握一般的知识点会有很大帮助。"; |
163 | } else if (after >= 80) { | 163 | } else if (after >= 80) { |
164 | comment = "知识点掌握程度有进步,还要再继续学习,多练习,不断巩固。"; | 164 | comment = "知识点掌握程度有进步,还要再继续学习,多练习,不断巩固。"; |
165 | } else if (after >= 60) { | 165 | } else if (after >= 60) { |
166 | comment = "薄弱知识点还有进步空间,再多做一些类似题目来巩固知识点,继续努力。"; | 166 | comment = "薄弱知识点还有进步空间,再多做一些类似题目来巩固知识点,继续努力。"; |
167 | } else { | 167 | } else { |
168 | comment = "你的薄弱知识点还需要再深入了解,有不清楚的地方及时问老师,继续加油。"; | 168 | comment = "你的薄弱知识点还需要再深入了解,有不清楚的地方及时问老师,继续加油。"; |
169 | } | 169 | } |
170 | String percent = new DecimalFormat("0%").format(after / 100); | 170 | String percent = new DecimalFormat("0%").format(after / 100); |
171 | String temp = indent + "通过学习,你的薄弱知识点掌握程度为 %s," + comment; | 171 | String temp = indent + "通过学习,你的薄弱知识点掌握程度为 %s," + comment; |
172 | temp = String.format(temp, fromColor(percent, "#F24E38")); | 172 | temp = String.format(temp, fromColor(percent, "#F24E38")); |
173 | binding.tvWeakRate.setText(Html.fromHtml(temp, Html.FROM_HTML_MODE_COMPACT)); | 173 | binding.tvWeakRate.setText(Html.fromHtml(temp, Html.FROM_HTML_MODE_COMPACT)); |
174 | } | 174 | } |
175 | 175 | ||
176 | int exNo = 0, goodNo = 0, normalNo = 0, weakNo = 0; | 176 | int exNo = 0, goodNo = 0, normalNo = 0, weakNo = 0; |
177 | float total = 0; | 177 | float total = 0; |
178 | if (data.points != null) { | 178 | if (data.points != null) { |
179 | for (StDetail.Point point: data.points) { | 179 | for (StDetail.Point point: data.points) { |
180 | total += point.afterState; | 180 | total += point.afterState; |
181 | if (point.afterState >= 0.9) { | 181 | if (point.afterState >= 0.9) { |
182 | exNo ++; | 182 | exNo ++; |
183 | } else if (point.afterState >= 0.8) { | 183 | } else if (point.afterState >= 0.8) { |
184 | goodNo ++; | 184 | goodNo ++; |
185 | } else if (point.afterState >= 0.6) { | 185 | } else if (point.afterState >= 0.6) { |
186 | normalNo ++; | 186 | normalNo ++; |
187 | } else { | 187 | } else { |
188 | weakNo ++; | 188 | weakNo ++; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | float rate = 100f * data.correct / Math.max(data.total - data.unfinished, 1); | 193 | float rate = 100f * data.correct / Math.max(data.total - data.unfinished, 1); |
194 | binding.tvTotalRate.setText(new DecimalFormat("0").format(rate)); | 194 | binding.tvTotalRate.setText(new DecimalFormat("0").format(rate)); |
195 | binding.tvTotalCorrect.setText(String.valueOf(data.correct)); | 195 | binding.tvTotalCorrect.setText(String.valueOf(data.correct)); |
196 | binding.tvTotalError.setText(String.valueOf(data.total - data.correct - data.unfinished)); | 196 | binding.tvTotalError.setText(String.valueOf(data.total - data.correct - data.unfinished)); |
197 | binding.tvTotalBlank.setText(String.valueOf(data.unfinished)); | 197 | binding.tvTotalBlank.setText(String.valueOf(data.unfinished)); |
198 | if (data.total == 0) { | 198 | if (data.total == 0) { |
199 | binding.tvRating.setText(""); | 199 | binding.tvRating.setText(""); |
200 | } else { | 200 | } else { |
201 | String rateComment; | 201 | String rateComment; |
202 | String encComment; | 202 | String encComment; |
203 | if (rate >= 90) { | 203 | if (rate >= 90) { |
204 | rateComment = "知识点掌握得比较优秀,多练习多巩固掌握一般的知识点会有很大帮助。"; | 204 | rateComment = "知识点掌握得比较优秀,多练习多巩固掌握一般的知识点会有很大帮助。"; |
205 | encComment = "在未来的学习中,请保持这份优秀,继续挑战更难的题目,勇攀高峰"; | 205 | encComment = "在未来的学习中,请保持这份优秀,继续挑战更难的题目,勇攀高峰"; |
206 | } else if (rate >= 80) { | 206 | } else if (rate >= 80) { |
207 | rateComment = "知识点掌握程度有进步,还要再继续学习,多练习,不断巩固。"; | 207 | rateComment = "知识点掌握程度有进步,还要再继续学习,多练习,不断巩固。"; |
208 | encComment = "在未来的学习中,请保持这份优秀,继续挑战更难的题目,勇攀高峰"; | 208 | encComment = "在未来的学习中,请保持这份优秀,继续挑战更难的题目,勇攀高峰"; |
209 | } else if (rate >= 60) { | 209 | } else if (rate >= 60) { |
210 | rateComment = "薄弱知识点还有进步空间,再多做一些类似题目来巩固知识点,继续努力。"; | 210 | rateComment = "薄弱知识点还有进步空间,再多做一些类似题目来巩固知识点,继续努力。"; |
211 | encComment = "在未来的学习中,请不要灰心,继续努力"; | 211 | encComment = "在未来的学习中,请不要灰心,继续努力"; |
212 | } else { | 212 | } else { |
213 | rateComment = "你的薄弱知识点还需要再深入了解,有不清楚的地方及时问老师,继续加油。"; | 213 | rateComment = "你的薄弱知识点还需要再深入了解,有不清楚的地方及时问老师,继续加油。"; |
214 | encComment = "在未来的学习中,请不要灰心,继续努力"; | 214 | encComment = "在未来的学习中,请不要灰心,继续努力"; |
215 | } | 215 | } |
216 | 216 | ||
217 | String correctNumHt = fromColor(String.valueOf(data.correct), "#3BC3B6"); | 217 | String correctNumHt = fromColor(String.valueOf(data.correct), "#3BC3B6"); |
218 | String errNumHt = fromColor(String.valueOf(data.total - data.correct - data.unfinished), "#3BC3B6"); | 218 | String errNumHt = fromColor(String.valueOf(data.total - data.correct - data.unfinished), "#3BC3B6"); |
219 | StringBuilder pointComment = new StringBuilder("其中,答对题目 ") | 219 | StringBuilder pointComment = new StringBuilder("其中,答对题目 ") |
220 | .append(correctNumHt).append(" 个,答错题目 ") | 220 | .append(correctNumHt).append(" 个,答错题目 ") |
221 | .append(errNumHt).append(" 个"); | 221 | .append(errNumHt).append(" 个"); |
222 | if (exNo > 0) { | 222 | if (exNo > 0) { |
223 | pointComment.append(",").append(exNo).append(" 个知识点掌握的非常棒"); | 223 | pointComment.append(",").append(exNo).append(" 个知识点掌握的非常棒"); |
224 | } | 224 | } |
225 | if (weakNo > 0) { | 225 | if (weakNo > 0) { |
226 | pointComment.append(",").append(weakNo).append(" 个知识点掌握的还需努力,这部分还要再加强学习"); | 226 | pointComment.append(",").append(weakNo).append(" 个知识点掌握的还需努力,这部分还要再加强学习"); |
227 | } | 227 | } |
228 | pointComment.append("。"); | 228 | pointComment.append("。"); |
229 | String rateStr = new DecimalFormat("0%").format(rate / 100f); | 229 | String rateStr = new DecimalFormat("0%").format(rate / 100f); |
230 | String temp; | 230 | String temp; |
231 | if (type == 0) { | 231 | if (type == 0) { |
232 | temp = indent + "在本周作业中,你的综合正确率是 %s," + pointComment + rateComment + encComment; | 232 | temp = indent + "在本周作业中,你的综合正确率是 %s," + pointComment + rateComment + encComment; |
233 | } else { | 233 | } else { |
234 | temp = indent + "在本阶段作业中,你的综合正确率是 %s," + pointComment + rateComment + encComment; | 234 | temp = indent + "在本阶段作业中,你的综合正确率是 %s," + pointComment + rateComment + encComment; |
235 | } | 235 | } |
236 | temp = String.format(temp, fromColor(rateStr, "#3BC3B6")); | 236 | temp = String.format(temp, fromColor(rateStr, "#3BC3B6")); |
237 | binding.tvRating.setText(Html.fromHtml(temp, Html.FROM_HTML_MODE_COMPACT)); | 237 | binding.tvRating.setText(Html.fromHtml(temp, Html.FROM_HTML_MODE_COMPACT)); |
238 | } | 238 | } |
239 | 239 | ||
240 | List<Entry> entries = new ArrayList<>(); | 240 | List<Entry> entries = new ArrayList<>(); |
241 | if (type == 0) { | 241 | if (type == 0) { |
242 | entries.add(new Entry(1, data.mondayCorrection)); | 242 | entries.add(new Entry(1, data.mondayCorrection)); |
243 | entries.add(new Entry(2, data.tuesdayCorrection)); | 243 | entries.add(new Entry(2, data.tuesdayCorrection)); |
244 | entries.add(new Entry(3, data.wednesdayCorrection)); | 244 | entries.add(new Entry(3, data.wednesdayCorrection)); |
245 | entries.add(new Entry(4, data.thursdayCorrection)); | 245 | entries.add(new Entry(4, data.thursdayCorrection)); |
246 | entries.add(new Entry(5, data.fridayCorrection)); | 246 | entries.add(new Entry(5, data.fridayCorrection)); |
247 | } else { | 247 | } else { |
248 | for (int i = 0; i < data.correctionList.size(); i ++) { | 248 | for (int i = 0; i < data.correctionList.size(); i ++) { |
249 | StDetail.Correction c = data.correctionList.get(i); | 249 | StDetail.Correction c = data.correctionList.get(i); |
250 | entries.add(new Entry(i, c.correction)); | 250 | entries.add(new Entry(i, c.correction)); |
251 | } | 251 | } |
252 | XAxis xAxis = binding.lineChart.getXAxis(); | 252 | XAxis xAxis = binding.lineChart.getXAxis(); |
253 | xAxis.setLabelCount(Math.min(entries.size(), 5), true); | 253 | xAxis.setLabelCount(Math.min(entries.size(), 5), true); |
254 | xAxis.setValueFormatter(new ValueFormatter() { | 254 | xAxis.setValueFormatter(new ValueFormatter() { |
255 | SimpleDateFormat format = new SimpleDateFormat("M.d", Locale.CHINA); | 255 | SimpleDateFormat format = new SimpleDateFormat("M.d", Locale.CHINA); |
256 | @Override | 256 | @Override |
257 | public String getFormattedValue(float value) { | 257 | public String getFormattedValue(float value) { |
258 | int index = (int) value; | 258 | int index = (int) value; |
259 | if (index < 0 || index >= data.correctionList.size()) return ""; | 259 | if (index < 0 || index >= data.correctionList.size()) return ""; |
260 | Date date = data.correctionList.get(index).date; | 260 | Date date = data.correctionList.get(index).date; |
261 | return format.format(date); | 261 | return format.format(date); |
262 | } | 262 | } |
263 | }); | 263 | }); |
264 | } | 264 | } |
265 | 265 | ||
266 | LineDataSet set = new LineDataSet(entries, ""); | 266 | LineDataSet set = new LineDataSet(entries, ""); |
267 | set.setColor(0xFF3BC3B6); | 267 | set.setColor(0xFF3BC3B6); |
268 | set.setCircleColor(0xFF3BC3B6); | 268 | set.setCircleColor(0xFF3BC3B6); |
269 | set.setDrawFilled(true); | 269 | set.setDrawFilled(true); |
270 | set.setDrawCircles(type == 0 || entries.size() == 1); | 270 | set.setDrawCircles(type == 0 || entries.size() == 1); |
271 | set.setDrawValues(false); | 271 | set.setDrawValues(false); |
272 | set.setHighlightEnabled(false); | 272 | set.setHighlightEnabled(false); |
273 | set.setDrawHighlightIndicators(false); | 273 | set.setDrawHighlightIndicators(false); |
274 | set.setFillDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.bg_line_chart_fill2, null)); | 274 | set.setFillDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.bg_line_chart_fill2, null)); |
275 | binding.lineChart.setData(new LineData(set)); | 275 | binding.lineChart.setData(new LineData(set)); |
276 | binding.lineChart.invalidate(); | 276 | binding.lineChart.invalidate(); |
277 | 277 | ||
278 | if (!data.points.isEmpty()) { | 278 | if (!data.points.isEmpty()) { |
279 | binding.tvExcellent.setText(String.valueOf(exNo)); | 279 | binding.tvExcellent.setText(String.valueOf(exNo)); |
280 | binding.tvGood.setText(String.valueOf(goodNo)); | 280 | binding.tvGood.setText(String.valueOf(goodNo)); |
281 | binding.tvNormal.setText(String.valueOf(normalNo)); | 281 | binding.tvNormal.setText(String.valueOf(normalNo)); |
282 | binding.tvWeak.setText(String.valueOf(weakNo)); | 282 | binding.tvWeak.setText(String.valueOf(weakNo)); |
283 | 283 | ||
284 | float exRate = 100f * exNo / data.points.size(); | 284 | float exRate = 100f * exNo / data.points.size(); |
285 | float goodRate = 100f * goodNo / data.points.size(); | 285 | float goodRate = 100f * goodNo / data.points.size(); |
286 | float normalRate = 100f * normalNo / data.points.size(); | 286 | float normalRate = 100f * normalNo / data.points.size(); |
287 | float weakRate = 100f * weakNo / data.points.size(); | 287 | float weakRate = 100f * weakNo / data.points.size(); |
288 | binding.cpGood.setValue(goodRate + normalRate + weakRate); | 288 | binding.cpGood.setValue(goodRate + normalRate + weakRate); |
289 | binding.cpNormal.setValue(normalRate + weakRate); | 289 | binding.cpNormal.setValue(normalRate + weakRate); |
290 | binding.cpWeak.setValue(weakRate); | 290 | binding.cpWeak.setValue(weakRate); |
291 | binding.tvAvePoint.setText(new DecimalFormat("0").format(100f * total / data.points.size())); | 291 | binding.tvAvePoint.setText(new DecimalFormat("0").format(100f * total / data.points.size())); |
292 | } | 292 | } |
293 | 293 | ||
294 | List<StDetail.Point> points = new ArrayList<>(); | 294 | List<StDetail.Point> points = new ArrayList<>(); |
295 | for (StDetail.Point point: data.points) { | 295 | for (StDetail.Point point: data.points) { |
296 | if (point.beforeState < 1) points.add(point); | 296 | if (point.beforeState < 1) points.add(point); |
297 | } | 297 | } |
298 | binding.tableRoot.setClipToOutline(true); | 298 | binding.tableRoot.setClipToOutline(true); |
299 | binding.tableWeekRoot.setClipToOutline(true); | 299 | binding.tableWeekRoot.setClipToOutline(true); |
300 | binding.rvPoint.setAdapter(new Adapter(points)); | 300 | binding.rvPoint.setAdapter(new Adapter(points)); |
301 | binding.rvWeekPoint.setAdapter(new WeekAdapter(data.points)); | 301 | binding.rvWeekPoint.setAdapter(new WeekAdapter(data.points)); |
302 | binding.tableRoot.setVisibility(points.isEmpty() ? View.GONE : View.VISIBLE); | 302 | binding.tableRoot.setVisibility(points.isEmpty() ? View.GONE : View.VISIBLE); |
303 | binding.flPointDesc.setVisibility(points.isEmpty() ? View.GONE : View.VISIBLE); | 303 | binding.flPointDesc.setVisibility(points.isEmpty() ? View.GONE : View.VISIBLE); |
304 | binding.flEmptyPoints.setVisibility(points.isEmpty() ? View.VISIBLE : View.GONE); | 304 | binding.flEmptyPoints.setVisibility(points.isEmpty() ? View.VISIBLE : View.GONE); |
305 | } | 305 | } |
306 | 306 | ||
307 | private void setupChart() { | 307 | private void setupChart() { |
308 | binding.lineChart.getLegend().setForm(Legend.LegendForm.NONE); | 308 | binding.lineChart.getLegend().setForm(Legend.LegendForm.NONE); |
309 | binding.lineChart.setScaleEnabled(false); | 309 | binding.lineChart.setScaleEnabled(false); |
310 | binding.lineChart.setTouchEnabled(false); | 310 | binding.lineChart.setTouchEnabled(false); |
311 | binding.lineChart.setDescription(null); | 311 | binding.lineChart.setDescription(null); |
312 | binding.lineChart.getAxisRight().setEnabled(false); | 312 | binding.lineChart.getAxisRight().setEnabled(false); |
313 | YAxis yAxis = binding.lineChart.getAxisLeft(); | 313 | YAxis yAxis = binding.lineChart.getAxisLeft(); |
314 | yAxis.setDrawAxisLine(false); | 314 | yAxis.setDrawAxisLine(false); |
315 | yAxis.setDrawGridLines(true); | 315 | yAxis.setDrawGridLines(true); |
316 | yAxis.setGridColor(0xFFDDDDDD); | 316 | yAxis.setGridColor(0xFFDDDDDD); |
317 | yAxis.setTextColor(0xFF333333); | 317 | yAxis.setTextColor(0xFF333333); |
318 | if (type == 0) { | 318 | if (type == 0) { |
319 | yAxis.setTextSize(16); | 319 | yAxis.setTextSize(16); |
320 | yAxis.setXOffset(16); | 320 | yAxis.setXOffset(16); |
321 | } else { | 321 | } else { |
322 | yAxis.setTextSize(13); | 322 | yAxis.setTextSize(13); |
323 | } | 323 | } |
324 | yAxis.setAxisMinimum(0); | 324 | yAxis.setAxisMinimum(0); |
325 | yAxis.setAxisMaximum(1); | 325 | yAxis.setAxisMaximum(1); |
326 | yAxis.setLabelCount(5, true); | 326 | yAxis.setLabelCount(5, true); |
327 | yAxis.setValueFormatter(new ValueFormatter() { | 327 | yAxis.setValueFormatter(new ValueFormatter() { |
328 | @Override | 328 | @Override |
329 | public String getFormattedValue(float value) { | 329 | public String getFormattedValue(float value) { |
330 | return new DecimalFormat("0%").format(value); | 330 | return new DecimalFormat("0%").format(value); |
331 | } | 331 | } |
332 | }); | 332 | }); |
333 | 333 | ||
334 | XAxis xAxis = binding.lineChart.getXAxis(); | 334 | XAxis xAxis = binding.lineChart.getXAxis(); |
335 | xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); | 335 | xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); |
336 | xAxis.setDrawAxisLine(false); | 336 | xAxis.setDrawAxisLine(false); |
337 | xAxis.setDrawGridLines(false); | 337 | xAxis.setDrawGridLines(false); |
338 | xAxis.setTextColor(0xFF333333); | 338 | xAxis.setTextColor(0xFF333333); |
339 | xAxis.setTextSize(16); | 339 | xAxis.setTextSize(16); |
340 | xAxis.setYOffset(16); | 340 | xAxis.setYOffset(16); |
341 | if (type == 0) { | 341 | if (type == 0) { |
342 | xAxis.setAxisMinimum(0.5f); | 342 | xAxis.setAxisMinimum(0.5f); |
343 | xAxis.setAxisMaximum(5.5f); | 343 | xAxis.setAxisMaximum(5.5f); |
344 | xAxis.setLabelCount(11, true); | 344 | xAxis.setLabelCount(11, true); |
345 | xAxis.setValueFormatter(new ValueFormatter() { | 345 | xAxis.setValueFormatter(new ValueFormatter() { |
346 | @Override | 346 | @Override |
347 | public String getFormattedValue(float value) { | 347 | public String getFormattedValue(float value) { |
348 | if (value == 1) { | 348 | if (value == 1) { |
349 | return "周一"; | 349 | return "周一"; |
350 | } else if (value == 2) { | 350 | } else if (value == 2) { |
351 | return "周二"; | 351 | return "周二"; |
352 | } else if (value == 3) { | 352 | } else if (value == 3) { |
353 | return "周三"; | 353 | return "周三"; |
354 | } else if (value == 4) { | 354 | } else if (value == 4) { |
355 | return "周四"; | 355 | return "周四"; |
356 | } else if (value == 5) { | 356 | } else if (value == 5) { |
357 | return "周五"; | 357 | return "周五"; |
358 | } | 358 | } |
359 | return ""; | 359 | return ""; |
360 | } | 360 | } |
361 | }); | 361 | }); |
362 | } else { | 362 | } else { |
363 | xAxis.setTextSize(13); | 363 | xAxis.setTextSize(13); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | private String fromColor(String str, String color) { | 367 | private String fromColor(String str, String color) { |
368 | return String.format("<font color='%s'><b>%s</b></font>", color, str); | 368 | return String.format("<font color='%s'><b>%s</b></font>", color, str); |
369 | } | 369 | } |
370 | 370 | ||
371 | private void switchPage() { | 371 | private void switchPage() { |
372 | Intent intent = new Intent(getIntent()); | 372 | Intent intent = new Intent(getIntent()); |
373 | intent.putExtra("a4", !a4); | 373 | intent.putExtra("a4", !a4); |
374 | startActivity(intent); | 374 | startActivity(intent); |
375 | finish(); | 375 | finish(); |
376 | } | 376 | } |
377 | 377 | ||
378 | private Uri prepareShare() { | 378 | private Uri prepareShare() { |
379 | try { | 379 | try { |
380 | binding.toolbar.setVisibility(View.INVISIBLE); | 380 | binding.toolbar.setVisibility(View.INVISIBLE); |
381 | Bitmap bitmap = BitmapUtils.shotView(binding.root); | 381 | Bitmap bitmap = BitmapUtils.shotView(binding.root); |
382 | binding.toolbar.setVisibility(View.VISIBLE); | 382 | binding.toolbar.setVisibility(View.VISIBLE); |
383 | 383 | ||
384 | String fileName = student.stuName + "_周作业学习报告_" + System.currentTimeMillis(); | 384 | String fileName = student.stuName + "_周作业学习报告_" + System.currentTimeMillis(); |
385 | return ContentUtil.saveBitmapToGallery(this, bitmap, fileName); | 385 | return ContentUtil.saveBitmapToGallery(this, bitmap, fileName); |
386 | } catch (Exception e) { | 386 | } catch (Exception e) { |
387 | e.printStackTrace(); | 387 | e.printStackTrace(); |
388 | } | 388 | } |
389 | return null; | 389 | return null; |
390 | } | 390 | } |
391 | 391 | ||
392 | @Override | 392 | @Override |
393 | protected ActivityHuyouDetailBinding getViewBinding() { | 393 | protected ActivityHuyouDetailBinding getViewBinding() { |
394 | a4 = getIntent().getBooleanExtra("a4", false); | 394 | a4 = getIntent().getBooleanExtra("a4", false); |
395 | View view; | 395 | View view; |
396 | if (a4) view = getLayoutInflater().inflate(R.layout.activity_huyou_detail_a4, null); | 396 | if (a4) view = getLayoutInflater().inflate(R.layout.activity_huyou_detail_a4, null); |
397 | else view = getLayoutInflater().inflate(R.layout.activity_huyou_detail, null); | 397 | else view = getLayoutInflater().inflate(R.layout.activity_huyou_detail, null); |
398 | return ActivityHuyouDetailBinding.bind(view); | 398 | return ActivityHuyouDetailBinding.bind(view); |
399 | } | 399 | } |
400 | 400 | ||
401 | public static class Adapter extends BaseQuickAdapter<StDetail.Point, BaseViewHolder> { | 401 | public static class Adapter extends BaseQuickAdapter<StDetail.Point, BaseViewHolder> { |
402 | 402 | ||
403 | public Adapter(@Nullable List<StDetail.Point> data) { | 403 | public Adapter(@Nullable List<StDetail.Point> data) { |
404 | super(R.layout.item_huyou_point, data); | 404 | super(R.layout.item_huyou_point, data); |
405 | } | 405 | } |
406 | 406 | ||
407 | @Override | 407 | @Override |
408 | protected void convert(@NonNull BaseViewHolder holder, StDetail.Point point) { | 408 | protected void convert(@NonNull BaseViewHolder holder, StDetail.Point point) { |
409 | DecimalFormat format1 = new DecimalFormat("0%"); | 409 | DecimalFormat format1 = new DecimalFormat("0%"); |
410 | DecimalFormat format2 = new DecimalFormat("0"); | 410 | DecimalFormat format2 = new DecimalFormat("0"); |
411 | holder.setText(R.id.tvName, point.pointName); | 411 | holder.setText(R.id.tvName, point.pointName); |
412 | holder.setText(R.id.tvBefore, format1.format(point.beforeState)); | 412 | holder.setText(R.id.tvBefore, format1.format(point.beforeState)); |
413 | holder.setText(R.id.tvAfter, format1.format(point.afterState)); | 413 | holder.setText(R.id.tvAfter, format1.format(point.afterState)); |
414 | holder.setText(R.id.tvGap, format2.format(point.gap * 100)); | 414 | holder.setText(R.id.tvGap, format2.format(point.gap * 100)); |
415 | holder.setGone(R.id.ivFlag, getData().indexOf(point) == 0); | 415 | holder.setGone(R.id.ivFlag, getData().indexOf(point) == 0); |
416 | holder.<TextView>getView(R.id.tvName).setTooltipText(point.pointName); | 416 | holder.<TextView>getView(R.id.tvName).setTooltipText(point.pointName); |
417 | 417 | ||
418 | TextView before = holder.getView(R.id.tvBeforeState); | 418 | TextView before = holder.getView(R.id.tvBeforeState); |
419 | TextView after = holder.getView(R.id.tvAfterState); | 419 | TextView after = holder.getView(R.id.tvAfterState); |
420 | 420 | ||
421 | if (point.beforeState >= 0.9) { | 421 | if (point.beforeState >= 0.9) { |
422 | before.setText("掌握优秀"); | 422 | before.setText("掌握优秀"); |
423 | before.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); | 423 | before.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); |
424 | } else if (point.beforeState >= 0.8) { | 424 | } else if (point.beforeState >= 0.8) { |
425 | before.setText("掌握良好"); | 425 | before.setText("掌握良好"); |
426 | before.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); | 426 | before.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); |
427 | } else if (point.beforeState >= 0.6) { | 427 | } else if (point.beforeState >= 0.6) { |
428 | before.setText("掌握一般"); | 428 | before.setText("掌握一般"); |
429 | before.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); | 429 | before.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); |
430 | } else { | 430 | } else { |
431 | before.setText("掌握薄弱"); | 431 | before.setText("掌握薄弱"); |
432 | before.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); | 432 | before.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); |
433 | } | 433 | } |
434 | if (point.afterState >= 0.9) { | 434 | if (point.afterState >= 0.9) { |
435 | after.setText("掌握优秀"); | 435 | after.setText("掌握优秀"); |
436 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); | 436 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); |
437 | } else if (point.afterState >= 0.8) { | 437 | } else if (point.afterState >= 0.8) { |
438 | after.setText("掌握良好"); | 438 | after.setText("掌握良好"); |
439 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); | 439 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); |
440 | } else if (point.afterState >= 0.6) { | 440 | } else if (point.afterState >= 0.6) { |
441 | after.setText("掌握一般"); | 441 | after.setText("掌握一般"); |
442 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); | 442 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); |
443 | } else { | 443 | } else { |
444 | after.setText("掌握薄弱"); | 444 | after.setText("掌握薄弱"); |
445 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); | 445 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); |
446 | } | 446 | } |
447 | 447 | ||
448 | holder.setText(R.id.tvHuyou, format1.format(point.correctness)); | 448 | holder.setText(R.id.tvHuyou, format1.format(point.correctness)); |
449 | } | 449 | } |
450 | 450 | ||
451 | } | 451 | } |
452 | 452 | ||
453 | public static class WeekAdapter extends BaseQuickAdapter<StDetail.Point, BaseViewHolder> { | 453 | public static class WeekAdapter extends BaseQuickAdapter<StDetail.Point, BaseViewHolder> { |
454 | public WeekAdapter(@Nullable List<StDetail.Point> data) { | 454 | public WeekAdapter(@Nullable List<StDetail.Point> data) { |
455 | super(R.layout.item_huyou_week_point, data); | 455 | super(R.layout.item_huyou_week_point, data); |
456 | } | 456 | } |
457 | 457 | ||
458 | @Override | 458 | @Override |
459 | protected void convert(@NonNull BaseViewHolder holder, StDetail.Point point) { | 459 | protected void convert(@NonNull BaseViewHolder holder, StDetail.Point point) { |
460 | holder.setText(R.id.tvName, point.pointName); | 460 | holder.setText(R.id.tvName, point.pointName); |
461 | 461 | ||
462 | TextView after = holder.getView(R.id.tvState); | 462 | TextView after = holder.getView(R.id.tvState); |
463 | if (point.afterState >= 0.9) { | 463 | if (point.afterState >= 0.9) { |
464 | after.setText("掌握优秀"); | 464 | after.setText("掌握优秀"); |
465 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); | 465 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF4FBB7A)); |
466 | } else if (point.afterState >= 0.8) { | 466 | } else if (point.afterState >= 0.8) { |
467 | after.setText("掌握良好"); | 467 | after.setText("掌握良好"); |
468 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); | 468 | after.setBackgroundTintList(ColorStateList.valueOf(0xFF489AFA)); |
469 | } else if (point.afterState >= 0.6) { | 469 | } else if (point.afterState >= 0.6) { |
470 | after.setText("掌握一般"); | 470 | after.setText("掌握一般"); |
471 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); | 471 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFF58725)); |
472 | } else { | 472 | } else { |
473 | after.setText("掌握薄弱"); | 473 | after.setText("掌握薄弱"); |
474 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); | 474 | after.setBackgroundTintList(ColorStateList.valueOf(0xFFEA5127)); |
475 | } | 475 | } |
476 | 476 | ||
477 | DecimalFormat format1 = new DecimalFormat("0%"); | 477 | DecimalFormat format1 = new DecimalFormat("0%"); |
478 | holder.setText(R.id.tvHuyou, format1.format(point.correctness)); | 478 | holder.setText(R.id.tvHuyou, format1.format(point.afterState)); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | } | 482 | } |
483 | 483 |