Commit 2d8005994d5896c255ea5fb35afd4f1ee8725128
1 parent
ff207bc53e
Exists in
master
查看题目详情
Showing
10 changed files
with
327 additions
and
1 deletions
 
Show diff stats
app/src/main/AndroidManifest.xml
| ... | ... | @@ -155,6 +155,7 @@ | 
| 155 | 155 | <activity android:name=".HomeworkDetailActivity" /> | 
| 156 | 156 | <activity android:name=".HomeworkSelectActivity" /> | 
| 157 | 157 | <activity android:name=".HomeworkFeedbackActivity" /> | 
| 158 | + <activity android:name=".HomeworkTopicActivity" /> | |
| 158 | 159 | |
| 159 | 160 | <provider | 
| 160 | 161 | android:name="androidx.core.content.FileProvider" | ... | ... | 
app/src/main/java/com/hjx/parent/HomeworkFeedbackActivity.java
| 1 | 1 | package com.hjx.parent; | 
| 2 | 2 | |
| 3 | 3 | import android.annotation.SuppressLint; | 
| 4 | +import android.content.Intent; | |
| 4 | 5 | import android.os.Bundle; | 
| 5 | 6 | import android.view.View; | 
| 6 | 7 | import android.widget.ImageView; | 
| ... | ... | @@ -62,13 +63,27 @@ public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFee | 
| 62 | 63 | binding.tvPercent.setText(new DecimalFormat("0%").format(1f * correctNo / mList.size())); | 
| 63 | 64 | |
| 64 | 65 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); | 
| 65 | - binding.rvCorrect.setAdapter(new NumberAdapter(mList)); | |
| 66 | + NumberAdapter numberAdapter = new NumberAdapter(mList); | |
| 67 | + binding.rvCorrect.setAdapter(numberAdapter); | |
| 66 | 68 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); | 
| 67 | 69 | binding.rvError.setAdapter(new EvalAdapter(errorList)); | 
| 68 | 70 | |
| 71 | + binding.btnDetail.setOnClickListener(v -> { | |
| 72 | + viewTopicDetail(0); | |
| 73 | + }); | |
| 74 | + numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | |
| 75 | + viewTopicDetail(i); | |
| 76 | + }); | |
| 69 | 77 | binding.btnPublish.setOnClickListener(v -> submit()); | 
| 70 | 78 | } | 
| 71 | 79 | |
| 80 | + private void viewTopicDetail(int position) { | |
| 81 | + Intent intent = new Intent(this, HomeworkTopicActivity.class); | |
| 82 | + intent.putExtra("list", mList); | |
| 83 | + intent.putExtra("position", position); | |
| 84 | + startActivity(intent); | |
| 85 | + } | |
| 86 | + | |
| 72 | 87 | @SuppressLint("CheckResult") | 
| 73 | 88 | private void submit() { | 
| 74 | 89 | Map<String, Object> body = new HashMap<>(); | ... | ... | 
app/src/main/java/com/hjx/parent/HomeworkTopicActivity.java
| ... | ... | @@ -0,0 +1,84 @@ | 
| 1 | +package com.hjx.parent; | |
| 2 | + | |
| 3 | +import android.annotation.SuppressLint; | |
| 4 | +import android.content.res.ColorStateList; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.widget.TextView; | |
| 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.gson.Gson; | |
| 15 | +import com.hjx.parent.databinding.ActivityTopicDetailBinding; | |
| 16 | +import com.hjx.parent.rx.BaseRxActivity; | |
| 17 | +import com.prws.common.bean.homework.HomeWork; | |
| 18 | +import com.prws.common.bean.homework.KeyValue; | |
| 19 | + | |
| 20 | +import java.util.ArrayList; | |
| 21 | +import java.util.List; | |
| 22 | + | |
| 23 | +public class HomeworkTopicActivity extends BaseRxActivity<ActivityTopicDetailBinding> { | |
| 24 | + private ArrayList<HomeWork> mList; | |
| 25 | + private int position; | |
| 26 | + | |
| 27 | + @SuppressWarnings("unchecked") | |
| 28 | + @Override | |
| 29 | + public void initView(Bundle savedInstanceState) { | |
| 30 | + mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | |
| 31 | + position = getIntent().getIntExtra("position", 0); | |
| 32 | + binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | |
| 33 | + NumberAdapter adapter = new NumberAdapter(mList); | |
| 34 | + binding.rvNumber.setAdapter(adapter); | |
| 35 | + | |
| 36 | + showTopic(position); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @SuppressLint("SetTextI18n") | |
| 40 | + private void showTopic(int position) { | |
| 41 | + if (position < 0 || position >= mList.size()) return; | |
| 42 | + this.position = position; | |
| 43 | + binding.btnPre.setEnabled(position > 0); | |
| 44 | + binding.btnNext.setEnabled(position < mList.size() - 1); | |
| 45 | + binding.tvTitle.setText((position + 1) + "/" + mList.size()); | |
| 46 | + binding.tvNo.setText("题目" + (position + 1)); | |
| 47 | + | |
| 48 | + HomeWork homeWork = mList.get(position); | |
| 49 | + Glide.with(this).load(homeWork.url).into(binding.ivTopic); | |
| 50 | + Glide.with(this).load(homeWork.analyseUrl).into(binding.ivAnalyse); | |
| 51 | + String answer = homeWork.answer == null ? "" : homeWork.answer | |
| 52 | + .replace("<br />", "\n") | |
| 53 | + .replace("${", "") | |
| 54 | + .replace("}$", ""); | |
| 55 | + binding.tvAnswer.setText(answer); | |
| 56 | + if (homeWork.pointsObj == null) homeWork.formatPoints(new Gson()); | |
| 57 | + StringBuilder pointBuilder = new StringBuilder(); | |
| 58 | + for (KeyValue point: homeWork.pointsObj) { | |
| 59 | + pointBuilder.append("\n").append(point.Value); | |
| 60 | + } | |
| 61 | + binding.tvPoint.setText(homeWork.pointsObj.size() == 0 ? "" : pointBuilder.substring(1)); | |
| 62 | + } | |
| 63 | + | |
| 64 | + @Override | |
| 65 | + protected ActivityTopicDetailBinding getViewBinding() { | |
| 66 | + return ActivityTopicDetailBinding.inflate(getLayoutInflater()); | |
| 67 | + } | |
| 68 | + | |
| 69 | + static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | |
| 70 | + | |
| 71 | + public NumberAdapter(@Nullable List<HomeWork> data) { | |
| 72 | + super(R.layout.item_topic_number, data); | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | |
| 77 | + TextView textView = (TextView) holder.itemView; | |
| 78 | + textView.setText(String.valueOf(getData().indexOf(homeWork) + 1)); | |
| 79 | + | |
| 80 | + int color = homeWork.check ? 0xFFFF4133 : 0xFF4ABC78; | |
| 81 | + textView.setBackgroundTintList(ColorStateList.valueOf(color)); | |
| 82 | + } | |
| 83 | + } | |
| 84 | +} | ... | ... | 
app/src/main/res/color/color_btn_pre_state.xml
app/src/main/res/drawable/ic_analyse.xml
| ... | ... | @@ -0,0 +1,5 @@ | 
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:width="17dp" android:height="17dp" | |
| 4 | + android:drawable="@drawable/png_ic_analyse"/> | |
| 5 | +</layer-list> | |
| 0 | 6 | \ No newline at end of file | ... | ... | 
app/src/main/res/drawable/png_ic_analyse.png
2.85 KB
app/src/main/res/drawable/svg_pre.xml
| ... | ... | @@ -0,0 +1,10 @@ | 
| 1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | + android:width="8dp" | |
| 3 | + android:height="12dp" | |
| 4 | + android:viewportWidth="16" | |
| 5 | + android:viewportHeight="25"> | |
| 6 | + <path | |
| 7 | + android:pathData="M0.886,13.934L1.269,14.315L1.269,14.315L11.225,24.196C12.071,25.036 13.443,25.036 14.289,24.196L14.672,23.816C15.518,22.977 15.518,21.615 14.672,20.776L6.247,12.414L14.672,4.053C15.518,3.213 15.518,1.852 14.672,1.012L14.289,0.632C13.443,-0.207 12.071,-0.207 11.225,0.632L1.269,10.514L1.269,10.514L0.886,10.894C0.04,11.734 0.04,13.095 0.886,13.934Z" | |
| 8 | + android:fillColor="#333333" | |
| 9 | + android:fillType="evenOdd"/> | |
| 10 | +</vector> | ... | ... | 
app/src/main/res/layout/activity_homework_feedback.xml
app/src/main/res/layout/activity_topic_detail.xml
| ... | ... | @@ -0,0 +1,189 @@ | 
| 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:layout_width="match_parent" | |
| 7 | + android:layout_height="match_parent" | |
| 8 | + tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription"> | |
| 9 | + | |
| 10 | + <androidx.appcompat.widget.Toolbar | |
| 11 | + android:id="@+id/toolbar" | |
| 12 | + app:navigationIcon="@drawable/svg_back" | |
| 13 | + app:contentInsetStartWithNavigation="14dp" | |
| 14 | + android:paddingStart="-8dp" | |
| 15 | + android:paddingEnd="-8dp" | |
| 16 | + android:background="@color/white" | |
| 17 | + android:layout_width="match_parent" | |
| 18 | + android:layout_height="40dp"> | |
| 19 | + <TextView | |
| 20 | + android:id="@+id/tvTitle" | |
| 21 | + tools:text="1/6" | |
| 22 | + android:textSize="18sp" | |
| 23 | + android:textColor="#333" | |
| 24 | + android:textStyle="bold" | |
| 25 | + android:layout_gravity="center" | |
| 26 | + android:layout_width="wrap_content" | |
| 27 | + android:layout_height="wrap_content"/> | |
| 28 | + </androidx.appcompat.widget.Toolbar> | |
| 29 | + | |
| 30 | + <androidx.core.widget.NestedScrollView | |
| 31 | + android:layout_width="match_parent" | |
| 32 | + android:layout_height="0dp" | |
| 33 | + android:layout_weight="1"> | |
| 34 | + <LinearLayout | |
| 35 | + android:orientation="vertical" | |
| 36 | + android:paddingHorizontal="15dp" | |
| 37 | + android:layout_width="match_parent" | |
| 38 | + android:layout_height="wrap_content"> | |
| 39 | + | |
| 40 | + <androidx.recyclerview.widget.RecyclerView | |
| 41 | + android:id="@+id/rvNumber" | |
| 42 | + android:orientation="horizontal" | |
| 43 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | |
| 44 | + android:layout_marginTop="15dp" | |
| 45 | + android:layout_width="match_parent" | |
| 46 | + android:layout_height="wrap_content"/> | |
| 47 | + | |
| 48 | + <LinearLayout | |
| 49 | + android:orientation="vertical" | |
| 50 | + android:layout_marginTop="15dp" | |
| 51 | + android:background="@drawable/shape_radius_5" | |
| 52 | + android:backgroundTint="@color/white" | |
| 53 | + android:layout_width="match_parent" | |
| 54 | + android:layout_height="wrap_content"> | |
| 55 | + <TextView | |
| 56 | + android:id="@+id/tvNo" | |
| 57 | + tools:text="题目8" | |
| 58 | + android:layout_width="40dp" | |
| 59 | + android:layout_height="16dp" | |
| 60 | + android:layout_gravity="end" | |
| 61 | + android:background="@drawable/bg_homework_num" | |
| 62 | + android:gravity="center" | |
| 63 | + android:textColor="@color/white" | |
| 64 | + android:textSize="9sp" /> | |
| 65 | + <ImageView | |
| 66 | + android:id="@+id/ivTopic" | |
| 67 | + android:adjustViewBounds="true" | |
| 68 | + android:layout_marginHorizontal="20dp" | |
| 69 | + android:layout_marginVertical="16dp" | |
| 70 | + android:layout_width="match_parent" | |
| 71 | + android:layout_height="wrap_content"/> | |
| 72 | + </LinearLayout> | |
| 73 | + | |
| 74 | + <LinearLayout | |
| 75 | + android:orientation="vertical" | |
| 76 | + android:layout_marginTop="15dp" | |
| 77 | + android:background="@drawable/shape_radius_5" | |
| 78 | + android:backgroundTint="@color/white" | |
| 79 | + android:layout_width="match_parent" | |
| 80 | + android:layout_height="wrap_content"> | |
| 81 | + <androidx.appcompat.widget.AppCompatTextView | |
| 82 | + android:text="解析" | |
| 83 | + android:layout_width="wrap_content" | |
| 84 | + android:layout_height="wrap_content" | |
| 85 | + android:layout_marginTop="15dp" | |
| 86 | + android:layout_marginHorizontal="15dp" | |
| 87 | + android:drawableStart="@drawable/ic_analyse" | |
| 88 | + android:drawablePadding="5dp" | |
| 89 | + android:gravity="center|center_vertical" | |
| 90 | + android:textStyle="bold" | |
| 91 | + android:textColor="#333" | |
| 92 | + android:textSize="16sp" /> | |
| 93 | + <ImageView | |
| 94 | + android:id="@+id/ivAnalyse" | |
| 95 | + android:adjustViewBounds="true" | |
| 96 | + android:layout_marginHorizontal="15dp" | |
| 97 | + android:layout_marginVertical="15dp" | |
| 98 | + android:layout_width="match_parent" | |
| 99 | + android:layout_height="wrap_content"/> | |
| 100 | + </LinearLayout> | |
| 101 | + | |
| 102 | + <LinearLayout | |
| 103 | + android:orientation="vertical" | |
| 104 | + android:layout_marginTop="15dp" | |
| 105 | + android:background="@drawable/shape_radius_5" | |
| 106 | + android:backgroundTint="@color/white" | |
| 107 | + android:layout_width="match_parent" | |
| 108 | + android:layout_height="wrap_content"> | |
| 109 | + <androidx.appcompat.widget.AppCompatTextView | |
| 110 | + android:text="答案" | |
| 111 | + android:layout_width="wrap_content" | |
| 112 | + android:layout_height="wrap_content" | |
| 113 | + android:layout_marginTop="15dp" | |
| 114 | + android:layout_marginHorizontal="15dp" | |
| 115 | + android:drawableStart="@drawable/ic_analyse" | |
| 116 | + android:drawablePadding="5dp" | |
| 117 | + android:gravity="center|center_vertical" | |
| 118 | + android:textStyle="bold" | |
| 119 | + android:textColor="#333" | |
| 120 | + android:textSize="16sp" /> | |
| 121 | + <TextView | |
| 122 | + android:id="@+id/tvAnswer" | |
| 123 | + android:textSize="12sp" | |
| 124 | + android:textColor="#333" | |
| 125 | + android:layout_margin="15dp" | |
| 126 | + android:layout_width="match_parent" | |
| 127 | + android:layout_height="wrap_content"/> | |
| 128 | + </LinearLayout> | |
| 129 | + | |
| 130 | + <LinearLayout | |
| 131 | + android:orientation="vertical" | |
| 132 | + android:layout_marginTop="15dp" | |
| 133 | + android:background="@drawable/shape_radius_5" | |
| 134 | + android:backgroundTint="@color/white" | |
| 135 | + android:layout_width="match_parent" | |
| 136 | + android:layout_height="wrap_content"> | |
| 137 | + <androidx.appcompat.widget.AppCompatTextView | |
| 138 | + android:text="知识点" | |
| 139 | + android:layout_width="wrap_content" | |
| 140 | + android:layout_height="wrap_content" | |
| 141 | + android:layout_marginTop="15dp" | |
| 142 | + android:layout_marginHorizontal="15dp" | |
| 143 | + android:drawableStart="@drawable/ic_analyse" | |
| 144 | + android:drawablePadding="5dp" | |
| 145 | + android:gravity="center|center_vertical" | |
| 146 | + android:textStyle="bold" | |
| 147 | + android:textColor="#333" | |
| 148 | + android:textSize="16sp" /> | |
| 149 | + <TextView | |
| 150 | + android:id="@+id/tvPoint" | |
| 151 | + android:textSize="12sp" | |
| 152 | + android:textColor="#333" | |
| 153 | + android:layout_margin="15dp" | |
| 154 | + android:layout_width="match_parent" | |
| 155 | + android:layout_height="wrap_content"/> | |
| 156 | + </LinearLayout> | |
| 157 | + | |
| 158 | + </LinearLayout> | |
| 159 | + </androidx.core.widget.NestedScrollView> | |
| 160 | + | |
| 161 | + <LinearLayout | |
| 162 | + android:orientation="horizontal" | |
| 163 | + android:gravity="center_vertical" | |
| 164 | + android:paddingHorizontal="15dp" | |
| 165 | + android:layout_marginVertical="15dp" | |
| 166 | + android:layout_width="match_parent" | |
| 167 | + android:layout_height="wrap_content"> | |
| 168 | + <androidx.constraintlayout.utils.widget.ImageFilterView | |
| 169 | + android:id="@+id/btnPre" | |
| 170 | + app:round="10dp" | |
| 171 | + android:src="@drawable/svg_pre" | |
| 172 | + android:tint="@color/color_btn_pre_state" | |
| 173 | + android:background="@color/white" | |
| 174 | + android:paddingHorizontal="6dp" | |
| 175 | + android:layout_width="20dp" | |
| 176 | + android:layout_height="20dp"/> | |
| 177 | + <Space style="@style/empty_space"/> | |
| 178 | + <androidx.constraintlayout.utils.widget.ImageFilterView | |
| 179 | + android:id="@+id/btnNext" | |
| 180 | + android:rotation="180" | |
| 181 | + app:round="10dp" | |
| 182 | + android:src="@drawable/svg_pre" | |
| 183 | + android:tint="@color/color_btn_pre_state" | |
| 184 | + android:background="@color/white" | |
| 185 | + android:paddingHorizontal="6dp" | |
| 186 | + android:layout_width="20dp" | |
| 187 | + android:layout_height="20dp"/> | |
| 188 | + </LinearLayout> | |
| 189 | +</LinearLayout> | |
| 0 | 190 | \ No newline at end of file | ... | ... | 
app/src/main/res/layout/item_topic_number.xml
| ... | ... | @@ -0,0 +1,16 @@ | 
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<TextView 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:layout_marginEnd="15dp" | |
| 6 | + android:background="@drawable/shape_radius_5" | |
| 7 | + android:backgroundTint="#FF4133" | |
| 8 | + tools:text="8" | |
| 9 | + android:gravity="center" | |
| 10 | + android:textSize="14sp" | |
| 11 | + android:textColor="@color/white" | |
| 12 | + android:textStyle="bold" | |
| 13 | + android:layout_width="25dp" | |
| 14 | + android:layout_height="25dp"> | |
| 15 | + | |
| 16 | +</TextView> | |
| 0 | 17 | \ No newline at end of file | ... | ... |