Commit 7083c3e3a1e467b3e5bacb2de649f61a9acce234

Authored by shixianjie
1 parent 07abc9da63
Exists in master

作业分享页面添加未做题

app/src/main/java/com/hjx/parent/HomeworkShareActivity.java
... ... @@ -12,6 +12,7 @@ import android.widget.LinearLayout;
12 12 import android.widget.TextView;
13 13  
14 14 import androidx.annotation.NonNull;
  15 +import androidx.annotation.Nullable;
15 16  
16 17 import com.bumptech.glide.Glide;
17 18 import com.chad.library.adapter.base.BaseQuickAdapter;
... ... @@ -114,18 +115,22 @@ public class HomeworkShareActivity extends BaseRxActivity<ActivityHomeworkShareB
114 115  
115 116 String temp = indent + "在本次作业中,答对题目有 %s 道,%s掌握的很好;答错题目有 %s 道,错题涵盖的知识点主要有%s,这部分还要再加强学习。错题老师已经帮你收录到错题本中,要记得复习整理错题,及时消灭薄弱知识点。";
116 117 List<HomeWork> errorList = new ArrayList<>();
  118 + List<HomeWork> blankList = new ArrayList<>();
117 119 if (detail.getHomeworkList() != null && detail.getHomeworkList().size() != 0) {
118 120 int total = detail.getHomeworkList().size();
119   - int correctNum = 0;
  121 + int correctNum = 0, blankNumber = 0;
120 122 Set<KeyValue> correctSet = new HashSet<>();
121 123 Set<KeyValue> errorSet = new HashSet<>();
122 124 for (HomeWork homeWork: detail.getHomeworkList()) {
123 125 if (homeWork.correction == 0) {
124 126 correctNum ++;
125 127 correctSet.addAll(homeWork.pointsObj);
126   - } else {
  128 + } else if (homeWork.correction == 1){
127 129 errorList.add(homeWork);
128 130 errorSet.addAll(homeWork.pointsObj);
  131 + } else if (homeWork.correction == 2) {
  132 + blankList.add(homeWork);
  133 + blankNumber ++;
129 134 }
130 135 }
131 136 StringBuilder correctPoint = new StringBuilder();
... ... @@ -136,11 +141,12 @@ public class HomeworkShareActivity extends BaseRxActivity&lt;ActivityHomeworkShareB
136 141 for (KeyValue point: errorSet) {
137 142 errorPoint.append("、").append(point.Value);
138 143 }
139   - float rate = 100f * correctNum / total;
  144 + float rate = 100f * correctNum / Math.max(total - blankNumber, 1);
140 145 int errorNum = total - correctNum;
141 146 binding.tvPercent.setText(new DecimalFormat("0").format(rate));
142 147 binding.tvCorrect.setText(String.valueOf(correctNum));
143 148 binding.tvWrong.setText(String.valueOf(errorNum));
  149 + binding.tvBlank.setText(String.valueOf(blankNumber));
144 150  
145 151 String correct = "-", error = "-";
146 152 if (correctPoint.length() != 0) correct = correctPoint.substring(1);
... ... @@ -164,6 +170,8 @@ public class HomeworkShareActivity extends BaseRxActivity&lt;ActivityHomeworkShareB
164 170 }
165 171  
166 172 mAdapter.setNewData(errorList);
  173 + binding.rvBlank.setAdapter(new BlankAdapter(blankList));
  174 + binding.viewBlank.setVisibility(blankList.isEmpty() ? View.GONE : View.VISIBLE);
167 175 }
168 176  
169 177 private String fromColor(String str, String color) {
... ... @@ -196,6 +204,19 @@ public class HomeworkShareActivity extends BaseRxActivity&lt;ActivityHomeworkShareB
196 204 return s;
197 205 }
198 206  
  207 + public static class BlankAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> {
  208 +
  209 + public BlankAdapter(@Nullable List<HomeWork> data) {
  210 + super(R.layout.item_huyou_daily_blank, data);
  211 + }
  212 +
  213 + @Override
  214 + protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) {
  215 + ImageView imageView = holder.getView(R.id.imageView);
  216 + Glide.with(mContext).load(homeWork.url).into(imageView);
  217 + }
  218 + }
  219 +
199 220 public static class ErrorAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> {
200 221  
201 222 public ErrorAdapter() {
... ...
app/src/main/res/layout/activity_homework_share.xml
... ... @@ -7,7 +7,7 @@
7 7 android:background="#489AFA"
8 8 android:layout_width="match_parent"
9 9 android:layout_height="match_parent"
10   - tools:ignore="HardcodedText,ContentDescription">
  10 + tools:ignore="HardcodedText,ContentDescription,SmallSp">
11 11  
12 12 <androidx.core.widget.NestedScrollView
13 13 android:layout_width="match_parent"
... ... @@ -31,6 +31,7 @@
31 31 android:tint="@color/white"
32 32 android:src="@drawable/svg_arrow_head_start_black"
33 33 android:paddingEnd="16dp"
  34 + android:paddingStart="0px"
34 35 android:layout_width="wrap_content"
35 36 android:layout_height="wrap_content"/>
36 37  
... ... @@ -112,6 +113,7 @@
112 113 android:layout_weight="1">
113 114 <LinearLayout
114 115 android:paddingEnd="20dp"
  116 + android:paddingStart="0px"
115 117 android:gravity="center_vertical"
116 118 android:layout_width="wrap_content"
117 119 android:layout_height="wrap_content">
... ... @@ -146,6 +148,7 @@
146 148 android:layout_weight="1">
147 149 <LinearLayout
148 150 android:paddingEnd="20dp"
  151 + android:paddingStart="0px"
149 152 android:gravity="center_vertical"
150 153 android:layout_width="wrap_content"
151 154 android:layout_height="wrap_content">
... ... @@ -180,6 +183,7 @@
180 183 android:layout_weight="1">
181 184 <LinearLayout
182 185 android:paddingEnd="20dp"
  186 + android:paddingStart="0px"
183 187 android:gravity="center_vertical"
184 188 android:layout_width="wrap_content"
185 189 android:layout_height="wrap_content">
... ... @@ -377,6 +381,52 @@
377 381 android:layout_height="wrap_content"/>
378 382 </LinearLayout>
379 383 </LinearLayout>
  384 + <LinearLayout
  385 + android:orientation="vertical"
  386 + android:gravity="center"
  387 + android:layout_width="0dp"
  388 + android:layout_height="match_parent"
  389 + android:layout_weight="1">
  390 + <LinearLayout
  391 + android:orientation="horizontal"
  392 + android:gravity="center_vertical"
  393 + android:layout_width="wrap_content"
  394 + android:layout_height="wrap_content">
  395 + <ImageView
  396 + android:src="@drawable/png_icon_statistical_accuracy"
  397 + android:layout_width="12dp"
  398 + android:layout_height="13dp"/>
  399 + <TextView
  400 + android:text="未做题数"
  401 + android:textSize="11sp"
  402 + android:textColor="#333"
  403 + android:textStyle="bold"
  404 + android:layout_marginStart="5dp"
  405 + android:layout_width="wrap_content"
  406 + android:layout_height="wrap_content"/>
  407 + </LinearLayout>
  408 + <LinearLayout
  409 + android:orientation="horizontal"
  410 + android:layout_marginTop="8dp"
  411 + android:layout_width="wrap_content"
  412 + android:layout_height="wrap_content">
  413 + <TextView
  414 + android:id="@+id/tvBlank"
  415 + tools:text="88"
  416 + android:textSize="14sp"
  417 + android:textColor="#489AFA"
  418 + android:textStyle="bold"
  419 + android:layout_width="wrap_content"
  420 + android:layout_height="wrap_content"/>
  421 + <TextView
  422 + android:text="道"
  423 + android:textSize="9sp"
  424 + android:textColor="#489AFA"
  425 + android:textStyle="bold"
  426 + android:layout_width="wrap_content"
  427 + android:layout_height="wrap_content" />
  428 + </LinearLayout>
  429 + </LinearLayout>
380 430 </LinearLayout>
381 431 <TextView
382 432 android:id="@+id/tvRating"
... ... @@ -426,6 +476,39 @@
426 476 </LinearLayout>
427 477  
428 478 <LinearLayout
  479 + android:id="@+id/viewBlank"
  480 + android:orientation="vertical"
  481 + android:background="@drawable/shape_radius_10"
  482 + android:backgroundTint="@color/white"
  483 + android:paddingHorizontal="16dp"
  484 + android:paddingBottom="16dp"
  485 + android:layout_marginTop="12dp"
  486 + android:layout_width="match_parent"
  487 + android:layout_height="wrap_content">
  488 + <TextView
  489 + android:text="未做题目"
  490 + android:textSize="16sp"
  491 + android:textStyle="bold"
  492 + android:textColor="#333"
  493 + android:paddingStart="24dp"
  494 + android:paddingEnd="4dp"
  495 + android:paddingTop="4dp"
  496 + android:background="@drawable/bg_homework_error"
  497 + android:layout_gravity="center_horizontal"
  498 + android:layout_marginTop="12dp"
  499 + android:layout_width="wrap_content"
  500 + android:layout_height="wrap_content"/>
  501 +
  502 + <androidx.recyclerview.widget.RecyclerView
  503 + android:id="@+id/rvBlank"
  504 + android:orientation="vertical"
  505 + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
  506 + android:layout_marginTop="12dp"
  507 + android:layout_width="match_parent"
  508 + android:layout_height="wrap_content"/>
  509 + </LinearLayout>
  510 +
  511 + <LinearLayout
429 512 android:id="@+id/flComment"
430 513 android:orientation="vertical"
431 514 android:background="@drawable/shape_radius_10"
... ...
app/src/main/res/layout/item_huyou_daily_blank.xml
... ... @@ -0,0 +1,18 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:orientation="vertical"
  6 + android:background="@drawable/bg_feedback_blank"
  7 + android:layout_width="match_parent"
  8 + android:layout_height="wrap_content"
  9 + tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription">
  10 +
  11 + <ImageView
  12 + android:id="@+id/imageView"
  13 + android:adjustViewBounds="true"
  14 + android:layout_margin="10dp"
  15 + android:layout_width="match_parent"
  16 + android:layout_height="wrap_content"/>
  17 +
  18 +</LinearLayout>
0 19 \ No newline at end of file
... ...