Commit 36364a3420312f092f3395f7fa5ab613ec9dc67f

Authored by shixianjie
1 parent eb171a0634
Exists in master

布局

app/src/main/java/com/hjx/parent/JudgeActivity.java
... ... @@ -52,6 +52,11 @@ public class JudgeActivity extends BaseRxActivity<ActivityJudgeBinding> {
52 52 prepareRects(rects);
53 53 });
54 54 });
  55 + binding.btnSelectAll.setOnClickListener(v -> {
  56 + if (mList.isEmpty()) return;
  57 + mList.forEach(it -> it.vb.getRoot().setSelected(true));
  58 + checkCount();
  59 + });
55 60 }
56 61  
57 62 private void prepareRects(List<Rect> rects) {
... ... @@ -90,11 +95,11 @@ public class JudgeActivity extends BaseRxActivity&lt;ActivityJudgeBinding&gt; {
90 95 .subscribe(it -> {
91 96 if (it.correctResult == 1) {
92 97 it.vb.ivResult.setImageResource(R.drawable.png_ic_judge_correct);
93   - it.vb.getRoot().setSelected(false);
94 98 } else if (it.correctResult == 2) {
95 99 it.vb.ivResult.setImageResource(R.drawable.png_ic_judge_wrong);
96   - it.vb.getRoot().setSelected(true);
97 100 }
  101 + it.vb.getRoot().setSelected(it.correctResult != 1);
  102 + checkCount();
98 103 }, th -> {
99 104 cancelLoadingDialog();
100 105 Log.e(getClass().getName(), "", th);
... ... @@ -118,8 +123,12 @@ public class JudgeActivity extends BaseRxActivity&lt;ActivityJudgeBinding&gt; {
118 123 return vb;
119 124 }
120 125  
  126 + @SuppressLint("SetTextI18n")
121 127 private void checkCount() {
122   - //
  128 + int count = (int) mList.stream().filter(it -> it.vb.getRoot().isSelected()).count();
  129 + if (count == 0) binding.btnAdd.setText("加入错题");
  130 + else binding.btnAdd.setText("加入错题(" + count + ")");
  131 + binding.btnAdd.setEnabled(count > 0);
123 132 }
124 133  
125 134 /** bitmapRect 转换为 viewRect */
... ... @@ -150,6 +159,8 @@ public class JudgeActivity extends BaseRxActivity&lt;ActivityJudgeBinding&gt; {
150 159 final LayoutJudgeRectBinding vb;
151 160  
152 161 String url;
  162 +
  163 + /** 0:未批改;1:正确;2:错误;3:未作答 */
153 164 int correctResult = 0;
154 165  
155 166 public JudgeCut(int index, Bitmap bitmap, Rect rect, LayoutJudgeRectBinding vb) {
... ...
app/src/main/res/drawable/check_circle_12.xml
... ... @@ -0,0 +1,15 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <item android:width="12dp" android:height="12dp">
  4 + <selector>
  5 + <item android:state_checked="true"
  6 + android:drawable="@drawable/png_ic_check_circle"/>
  7 + <item>
  8 + <shape>
  9 + <corners android:radius="20dp"/>
  10 + <stroke android:width="1.5dp" android:color="#333"/>
  11 + </shape>
  12 + </item>
  13 + </selector>
  14 + </item>
  15 +</layer-list>
0 16 \ No newline at end of file
... ...
app/src/main/res/drawable/png_ic_check_circle.png

1.05 KB

app/src/main/res/layout/activity_judge.xml
... ... @@ -39,4 +39,35 @@
39 39 android:layout_height="match_parent" />
40 40 </FrameLayout>
41 41  
  42 + <LinearLayout
  43 + android:orientation="horizontal"
  44 + android:gravity="center_vertical"
  45 + android:paddingHorizontal="16dp"
  46 + android:background="@color/white"
  47 + android:layout_width="match_parent"
  48 + android:layout_height="64dp">
  49 + <androidx.appcompat.widget.AppCompatTextView
  50 + android:id="@+id/btnSelectAll"
  51 + android:text="全选"
  52 + android:textSize="16sp"
  53 + android:textColor="#333"
  54 + android:gravity="center_vertical"
  55 + android:paddingHorizontal="8dp"
  56 + android:paddingVertical="4dp"
  57 + android:layout_width="wrap_content"
  58 + android:layout_height="wrap_content"/>
  59 +
  60 + <Space style="@style/empty_space"/>
  61 + <TextView
  62 + android:id="@+id/btnAdd"
  63 + android:text="加入错题"
  64 + android:textSize="16sp"
  65 + android:textColor="@color/white"
  66 + android:gravity="center"
  67 + android:background="@drawable/shape_radius_5"
  68 + android:backgroundTint="#1C90F3"
  69 + android:layout_width="112dp"
  70 + android:layout_height="36dp"/>
  71 + </LinearLayout>
  72 +
42 73 </LinearLayout>
43 74 \ No newline at end of file
... ...