Commit d454c09d63fecb8d7955baf3073e787de73ef4d6
1 parent
079c5d473a
Exists in
master
首页-最近作业
Showing
36 changed files
with
808 additions
and
186 deletions
Show diff stats
.idea/inspectionProfiles/Project_Default.xml
... | ... | @@ -0,0 +1,9 @@ |
1 | +<component name="InspectionProjectProfileManager"> | |
2 | + <profile version="1.0"> | |
3 | + <option name="myName" value="Project Default" /> | |
4 | + <inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false"> | |
5 | + <option name="m_reportAllNonLibraryCalls" value="false" /> | |
6 | + <option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.AbstractStringBuilder,capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.lang.Thread,interrupted,java.math.BigDecimal,.*,java.math.BigInteger,.*,java.net.InetAddress,.*,java.net.URI,.*,java.nio.channels.AsynchronousChannelGroup,.*,java.nio.channels.Channel,isOpen,java.nio.channels.FileChannel,open|map|lock|tryLock|write,java.nio.channels.ScatteringByteChannel,read,java.nio.channels.SocketChannel,open|socket|isConnected|isConnectionPending,java.util.Arrays,.*,java.util.Collections,(?!addAll).*,java.util.List,of,java.util.Map,of|ofEntries|entry,java.util.Set,of,java.util.UUID,.*,java.util.concurrent.BlockingQueue,offer|remove,java.util.concurrent.CountDownLatch,await|getCount,java.util.concurrent.ExecutorService,awaitTermination|isShutdown|isTerminated,java.util.concurrent.ForkJoinPool,awaitQuiescence,java.util.concurrent.Semaphore,tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads,java.util.concurrent.locks.Condition,await|awaitNanos|awaitUntil,java.util.concurrent.locks.Lock,tryLock|newCondition,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*,java.util.stream.DoubleStream,.*,java.util.stream.IntStream,.*,java.util.stream.LongStream,.*,java.util.stream.Stream,.*" /> | |
7 | + </inspection_tool> | |
8 | + </profile> | |
9 | +</component> | |
0 | 10 | \ No newline at end of file | ... | ... |
app/build.gradle
... | ... | @@ -78,4 +78,8 @@ dependencies { |
78 | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
79 | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
80 | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
81 | + | |
82 | + // rx | |
83 | + implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | |
84 | + implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | |
81 | 85 | } |
82 | 86 | \ No newline at end of file | ... | ... |
app/src/main/java/com/hjx/parent/adapter/ErrorAdapter.java
... | ... | @@ -31,7 +31,7 @@ import java.util.ArrayList; |
31 | 31 | import java.util.List; |
32 | 32 | |
33 | 33 | public class ErrorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
34 | - private List<TopicBean> list; | |
34 | + public List<TopicBean> list; | |
35 | 35 | private Context context; |
36 | 36 | public boolean edit; |
37 | 37 | private CheckInterface checkInterface; | ... | ... |
app/src/main/java/com/hjx/parent/adapter/HomeworkAdapter.java
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.hjx.parent.adapter; | |
2 | + | |
3 | +import androidx.annotation.NonNull; | |
4 | + | |
5 | +import com.chad.library.adapter.base.BaseQuickAdapter; | |
6 | +import com.chad.library.adapter.base.BaseViewHolder; | |
7 | +import com.hjx.parent.R; | |
8 | +import com.prws.common.bean.homework.HomeworkList; | |
9 | + | |
10 | +public class HomeworkAdapter extends BaseQuickAdapter<HomeworkList, BaseViewHolder> { | |
11 | + | |
12 | + public HomeworkAdapter() { | |
13 | + super(R.layout.item_homework); | |
14 | + } | |
15 | + | |
16 | + @Override | |
17 | + protected void convert(@NonNull BaseViewHolder helper, HomeworkList homework) { | |
18 | + helper.setText(R.id.tvName, homework.getName()); | |
19 | + helper.setText(R.id.tvGrade, homework.getGrade() + "-" + homework.getTerm()); | |
20 | + int subjectImg; | |
21 | + switch (homework.getSubject()) { | |
22 | + case "语文": | |
23 | + subjectImg = R.drawable.ic_chinese; | |
24 | + break; | |
25 | + case "英语": | |
26 | + subjectImg = R.drawable.ic_english; | |
27 | + break; | |
28 | + case "物理": | |
29 | + subjectImg = R.drawable.ic_physics; | |
30 | + break; | |
31 | + case "化学": | |
32 | + subjectImg = R.drawable.ic_chemistry; | |
33 | + break; | |
34 | + case "数学": | |
35 | + default: | |
36 | + subjectImg = R.drawable.ic_math; | |
37 | + } | |
38 | + helper.setImageResource(R.id.ivSubject, subjectImg); | |
39 | + } | |
40 | +} | ... | ... |
app/src/main/java/com/hjx/parent/fragment/BaseBindingFragment.java
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
... | ... | @@ -2,6 +2,7 @@ package com.hjx.parent.fragment; |
2 | 2 | |
3 | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | |
5 | +import android.annotation.SuppressLint; | |
5 | 6 | import android.content.Intent; |
6 | 7 | import android.graphics.Bitmap; |
7 | 8 | import android.graphics.BitmapFactory; |
... | ... | @@ -13,14 +14,11 @@ import android.util.Log; |
13 | 14 | import android.view.LayoutInflater; |
14 | 15 | import android.view.View; |
15 | 16 | import android.view.ViewGroup; |
16 | -import android.widget.ImageView; | |
17 | -import android.widget.LinearLayout; | |
18 | 17 | import android.widget.Toast; |
19 | 18 | |
20 | 19 | import androidx.annotation.NonNull; |
21 | 20 | import androidx.annotation.Nullable; |
22 | 21 | import androidx.core.content.FileProvider; |
23 | -import androidx.recyclerview.widget.LinearLayoutManager; | |
24 | 22 | import androidx.recyclerview.widget.RecyclerView; |
25 | 23 | |
26 | 24 | import com.bumptech.glide.Glide; |
... | ... | @@ -28,20 +26,20 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
28 | 26 | import com.bumptech.glide.request.RequestOptions; |
29 | 27 | import com.chad.library.adapter.base.BaseQuickAdapter; |
30 | 28 | import com.chad.library.adapter.base.BaseViewHolder; |
29 | +import com.google.android.material.tabs.TabLayout; | |
31 | 30 | import com.google.gson.Gson; |
32 | 31 | import com.hjq.permissions.OnPermissionCallback; |
33 | 32 | import com.hjq.permissions.Permission; |
34 | 33 | import com.hjq.permissions.XXPermissions; |
35 | -import com.hjx.parent.ChooseActivity; | |
36 | -import com.hjx.parent.ErrorBookActivity; | |
37 | 34 | import com.hjx.parent.ErrorListActivity; |
38 | 35 | import com.hjx.parent.ImageActivity; |
39 | 36 | import com.hjx.parent.R; |
40 | 37 | import com.hjx.parent.TeacherChooseActivity; |
41 | 38 | import com.hjx.parent.adapter.ErrorAdapter; |
39 | +import com.hjx.parent.adapter.HomeworkAdapter; | |
42 | 40 | import com.hjx.parent.bean.StudentBean; |
43 | -import com.hjx.parent.databinding.ActivityErrorBookBinding; | |
44 | 41 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
42 | +import com.hjx.parent.rx.BaseRxFragment; | |
45 | 43 | import com.prws.common.bean.PageInfo; |
46 | 44 | import com.prws.common.bean.ResponseResult; |
47 | 45 | import com.prws.common.bean.TopicBean; |
... | ... | @@ -51,6 +49,7 @@ import com.prws.common.utils.CommonUtil; |
51 | 49 | import com.prws.common.utils.ScreenUtils; |
52 | 50 | import com.prws.common.utils.SharedPreferencesUtil; |
53 | 51 | import com.prws.common.utils.dialog.MyButtomDialog; |
52 | +import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | |
54 | 53 | import com.zhangteng.imagepicker.bean.ImageInfo; |
55 | 54 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
56 | 55 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
... | ... | @@ -66,12 +65,15 @@ import java.util.List; |
66 | 65 | import java.util.Map; |
67 | 66 | |
68 | 67 | import io.reactivex.Observer; |
68 | +import io.reactivex.android.schedulers.AndroidSchedulers; | |
69 | 69 | import io.reactivex.disposables.Disposable; |
70 | +import io.reactivex.schedulers.Schedulers; | |
70 | 71 | |
71 | -public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> { | |
72 | +public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | |
72 | 73 | StudentBean studentBean; |
73 | 74 | private int subject; |
74 | - private ErrorAdapter adapter; | |
75 | + private ErrorAdapter errorAdapter; | |
76 | + private HomeworkAdapter homeworkAdapter; | |
75 | 77 | private int REQUEST_CODE_IMAGE = 123; |
76 | 78 | private String filePath; |
77 | 79 | |
... | ... | @@ -86,7 +88,7 @@ public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> |
86 | 88 | studentBean = new Gson().fromJson(student, StudentBean.class); |
87 | 89 | getBinding().tvChoose.setText(studentBean.getStuName()); |
88 | 90 | } catch (Exception e) { |
89 | - | |
91 | + e.printStackTrace(); | |
90 | 92 | } |
91 | 93 | } |
92 | 94 | |
... | ... | @@ -102,49 +104,31 @@ public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> |
102 | 104 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
103 | 105 | getBinding().tvName.setText(name); |
104 | 106 | refreshStudent(); |
105 | - getBinding().rlTakePhoto.post(new Runnable() { | |
106 | - @Override | |
107 | - public void run() { | |
108 | - LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getBinding().rlTakePhoto.getLayoutParams(); | |
109 | - layoutParams.width = CommonUtil.getScreenWidth(getContext()); | |
110 | - layoutParams.height = CommonUtil.getScreenWidth(getContext()) * 20 / 37; | |
111 | - getBinding().rlTakePhoto.setLayoutParams(layoutParams); | |
112 | - } | |
113 | - }); | |
114 | - getBinding().tvChoose.setOnClickListener(new View.OnClickListener() { | |
115 | - @Override | |
116 | - public void onClick(View v) { | |
117 | - startActivity(new Intent(getContext(), TeacherChooseActivity.class)); | |
118 | -// getActivity().finish(); | |
119 | - } | |
120 | - }); | |
121 | - getBinding().rlTakePhoto.setOnClickListener(new View.OnClickListener() { | |
122 | - @Override | |
123 | - public void onClick(View v) { | |
124 | - if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | |
125 | - XXPermissions.with(getContext()) | |
126 | - // 申请多个权限 | |
127 | - .permission(Permission.CAMERA).request(new OnPermissionCallback() { | |
128 | - @Override | |
129 | - public void onGranted(List<String> permissions, boolean all) { | |
130 | - if (all) { | |
131 | - //开启扫码界面 | |
132 | - showButtonDialog(); | |
133 | - } else { | |
134 | - Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | |
135 | - } | |
136 | - } | |
137 | - | |
138 | - @Override | |
139 | - public void onDenied(List<String> permissions, boolean never) { | |
140 | - XXPermissions.startPermissionActivity(getContext(), permissions); | |
107 | + getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | |
108 | + getBinding().rlTakePhoto.setOnClickListener(v -> { | |
109 | + if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | |
110 | + XXPermissions.with(getContext()) | |
111 | + // 申请多个权限 | |
112 | + .permission(Permission.CAMERA).request(new OnPermissionCallback() { | |
113 | + @Override | |
114 | + public void onGranted(List<String> permissions, boolean all) { | |
115 | + if (all) { | |
116 | + //开启扫码界面 | |
117 | + showButtonDialog(); | |
118 | + } else { | |
119 | + Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | |
141 | 120 | } |
142 | - }); | |
143 | - } else { | |
144 | - showButtonDialog(); | |
145 | - } | |
121 | + } | |
146 | 122 | |
123 | + @Override | |
124 | + public void onDenied(List<String> permissions, boolean never) { | |
125 | + XXPermissions.startPermissionActivity(getContext(), permissions); | |
126 | + } | |
127 | + }); | |
128 | + } else { | |
129 | + showButtonDialog(); | |
147 | 130 | } |
131 | + | |
148 | 132 | }); |
149 | 133 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
150 | 134 | @Override |
... | ... | @@ -175,26 +159,50 @@ public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> |
175 | 159 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
176 | 160 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
177 | 161 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
178 | - item.getConvertView().setOnClickListener(new View.OnClickListener() { | |
179 | - @Override | |
180 | - public void onClick(View v) { | |
181 | - if (subject != item.getAdapterPosition()) { | |
182 | - subject = item.getAdapterPosition(); | |
183 | - getError(getResources().getStringArray(R.array.filter_subject)[subject]); | |
162 | + item.getConvertView().setOnClickListener(v -> { | |
163 | + if (subject != item.getAdapterPosition()) { | |
164 | + subject = item.getAdapterPosition(); | |
165 | + String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | |
166 | + if (binding.tabLayout.getSelectedTabPosition() == 0) { | |
167 | + getError(subStr); | |
168 | + } else { | |
169 | + // nothing can do | |
184 | 170 | } |
185 | 171 | } |
186 | 172 | }); |
187 | 173 | } |
188 | 174 | }; |
189 | - getBinding().recycleSubject.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | |
190 | - getBinding().recycleSubject.setAdapter(adapter); | |
175 | + getBinding().rvSubject.setAdapter(adapter); | |
191 | 176 | subject = 0; |
192 | 177 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
193 | - getBinding().llAll.setOnClickListener(new View.OnClickListener() { | |
178 | + getBinding().llAll.setOnClickListener(v -> { | |
179 | + Intent intent = new Intent(getContext(), ErrorListActivity.class); | |
180 | + startActivity(intent); | |
181 | + }); | |
182 | + | |
183 | + errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | |
184 | + homeworkAdapter = new HomeworkAdapter(); | |
185 | + binding.rvMain.setAdapter(errorAdapter); | |
186 | + binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | |
187 | + binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | |
188 | + binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | |
194 | 189 | @Override |
195 | - public void onClick(View v) { | |
196 | - Intent intent = new Intent(getContext(), ErrorListActivity.class); | |
197 | - startActivity(intent); | |
190 | + public void onTabSelected(TabLayout.Tab tab) { | |
191 | + if (tab.getPosition() == 0) { | |
192 | + binding.rvMain.setAdapter(errorAdapter); | |
193 | + binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | |
194 | + binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | |
195 | + } else { | |
196 | + binding.rvMain.setAdapter(homeworkAdapter); | |
197 | + binding.rvMain.setVisibility(View.VISIBLE); | |
198 | + binding.llEmpty.setVisibility(View.GONE); | |
199 | + } | |
200 | + } | |
201 | + @Override | |
202 | + public void onTabUnselected(TabLayout.Tab tab) { | |
203 | + } | |
204 | + @Override | |
205 | + public void onTabReselected(TabLayout.Tab tab) { | |
198 | 206 | } |
199 | 207 | }); |
200 | 208 | } |
... | ... | @@ -247,61 +255,64 @@ public class ErrorFragment extends BaseBindingFragment<FragmentErrorBookBinding> |
247 | 255 | dialog.show(); |
248 | 256 | } |
249 | 257 | |
250 | - private void getError(String subject) { | |
251 | - if (studentBean != null) { | |
252 | - Map map = new HashMap(); | |
253 | - map.put("subject", subject); | |
254 | - map.put("stuId", studentBean.getStuId()); | |
255 | - map.put("pageSize", 5); | |
256 | - map.put("pageNum", 1); | |
257 | - NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | |
258 | - @Override | |
259 | - public void onSubscribe(Disposable d) { | |
260 | - | |
261 | - } | |
258 | + @SuppressLint("CheckResult") | |
259 | + protected void getHomework() { | |
260 | + if (studentBean == null) return; | |
261 | + NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | |
262 | + .subscribeOn(Schedulers.io()) | |
263 | + .observeOn(AndroidSchedulers.mainThread()) | |
264 | + .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | |
265 | + .map(ResponseResult::getData) | |
266 | + .subscribe((data, th) -> { | |
267 | + if (th != null) th.printStackTrace(); | |
268 | + homeworkAdapter.setNewData(data); | |
269 | + }); | |
270 | + } | |
262 | 271 | |
263 | - @Override | |
264 | - public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | |
265 | - if (result.getData() != null && result.getCode() == 200) { | |
266 | - List<TopicBean> topicBeans = result.getData().getList(); | |
267 | - loadError(topicBeans); | |
272 | + private void getError(String subject) { | |
273 | + if (studentBean == null) { | |
274 | + return; | |
275 | + } | |
276 | + Map<String, Object> map = new HashMap<>(); | |
277 | + map.put("subject", subject); | |
278 | + map.put("stuId", studentBean.getStuId()); | |
279 | + map.put("pageSize", 5); | |
280 | + map.put("pageNum", 1); | |
281 | + NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | |
282 | + @Override | |
283 | + public void onSubscribe(Disposable d) { | |
284 | + } | |
285 | + @Override | |
286 | + public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | |
287 | + if (result.getData() != null && result.getCode() == 200) { | |
288 | + List<TopicBean> topicBeans = result.getData().getList(); | |
289 | + errorAdapter.refresh(topicBeans); | |
290 | + if (binding.tabLayout.getSelectedTabPosition() == 0) { | |
291 | + if (topicBeans.size() > 0) { | |
292 | + getBinding().rvMain.setVisibility(View.VISIBLE); | |
293 | + getBinding().llEmpty.setVisibility(View.GONE); | |
294 | + } else { | |
295 | + getBinding().rvMain.setVisibility(View.GONE); | |
296 | + getBinding().llEmpty.setVisibility(View.VISIBLE); | |
297 | + } | |
268 | 298 | } |
269 | 299 | } |
270 | - | |
271 | - @Override | |
272 | - public void onError(Throwable e) { | |
273 | - e.toString(); | |
274 | - } | |
275 | - | |
276 | - @Override | |
277 | - public void onComplete() { | |
278 | - | |
279 | - } | |
280 | - }); | |
281 | - } | |
282 | - } | |
283 | - | |
284 | - private void loadError(List<TopicBean> list) { | |
285 | - if (list.size() > 0) { | |
286 | - getBinding().recycleError.setVisibility(View.VISIBLE); | |
287 | - getBinding().llEmpty.setVisibility(View.GONE); | |
288 | - if (adapter != null) { | |
289 | - adapter.refresh(list); | |
290 | - } else { | |
291 | - adapter = new ErrorAdapter(getActivity(), list, false); | |
292 | - getBinding().recycleError.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false)); | |
293 | - getBinding().recycleError.setAdapter(adapter); | |
294 | 300 | } |
295 | - } else { | |
296 | - getBinding().recycleError.setVisibility(View.GONE); | |
297 | - getBinding().llEmpty.setVisibility(View.VISIBLE); | |
298 | - } | |
301 | + @Override | |
302 | + public void onError(Throwable e) { | |
303 | + e.printStackTrace(); | |
304 | + } | |
305 | + @Override | |
306 | + public void onComplete() { | |
307 | + } | |
308 | + }); | |
299 | 309 | } |
300 | 310 | |
301 | 311 | @Override |
302 | 312 | public void onResume() { |
303 | 313 | super.onResume(); |
304 | 314 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
315 | + getHomework(); | |
305 | 316 | } |
306 | 317 | |
307 | 318 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | ... | ... |
app/src/main/java/com/hjx/parent/function/Function0.java
app/src/main/java/com/hjx/parent/function/Function1.java
app/src/main/java/com/hjx/parent/function/Function10.java
app/src/main/java/com/hjx/parent/function/Function11.java
app/src/main/java/com/hjx/parent/function/Function12.java
app/src/main/java/com/hjx/parent/function/Function13.java
app/src/main/java/com/hjx/parent/function/Function2.java
app/src/main/java/com/hjx/parent/function/Function3.java
app/src/main/java/com/hjx/parent/function/Function5.java
app/src/main/java/com/hjx/parent/rx/BaseRxActivity.java
... | ... | @@ -0,0 +1,57 @@ |
1 | +package com.hjx.parent.rx; | |
2 | + | |
3 | +import android.os.Bundle; | |
4 | + | |
5 | +import androidx.annotation.Nullable; | |
6 | +import androidx.viewbinding.ViewBinding; | |
7 | + | |
8 | +import com.hjx.parent.BaseActivity; | |
9 | +import com.trello.rxlifecycle2.android.ActivityEvent; | |
10 | + | |
11 | +import io.reactivex.subjects.BehaviorSubject; | |
12 | + | |
13 | +public abstract class BaseRxActivity<VB extends ViewBinding> extends BaseActivity<VB> implements ILifecycleActivity { | |
14 | + private BehaviorSubject<ActivityEvent> rxLifecycle = BehaviorSubject.create(); | |
15 | + | |
16 | + @Override | |
17 | + public BehaviorSubject<ActivityEvent> getRxLifecycle() { | |
18 | + return rxLifecycle; | |
19 | + } | |
20 | + | |
21 | + @Override | |
22 | + protected void onCreate(@Nullable Bundle savedInstanceState) { | |
23 | + super.onCreate(savedInstanceState); | |
24 | + rxLifecycle.onNext(ActivityEvent.CREATE); | |
25 | + } | |
26 | + | |
27 | + @Override | |
28 | + protected void onStart() { | |
29 | + super.onStart(); | |
30 | + rxLifecycle.onNext(ActivityEvent.START); | |
31 | + } | |
32 | + | |
33 | + @Override | |
34 | + protected void onResume() { | |
35 | + super.onResume(); | |
36 | + rxLifecycle.onNext(ActivityEvent.RESUME); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + protected void onPause() { | |
41 | + super.onPause(); | |
42 | + rxLifecycle.onNext(ActivityEvent.PAUSE); | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + protected void onStop() { | |
47 | + super.onStop(); | |
48 | + rxLifecycle.onNext(ActivityEvent.STOP); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + protected void onDestroy() { | |
53 | + super.onDestroy(); | |
54 | + rxLifecycle.onNext(ActivityEvent.DESTROY); | |
55 | + } | |
56 | + | |
57 | +} | ... | ... |
app/src/main/java/com/hjx/parent/rx/BaseRxFragment.java
... | ... | @@ -0,0 +1,84 @@ |
1 | +package com.hjx.parent.rx; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.os.Bundle; | |
5 | +import android.view.View; | |
6 | + | |
7 | +import androidx.annotation.NonNull; | |
8 | +import androidx.annotation.Nullable; | |
9 | +import androidx.viewbinding.ViewBinding; | |
10 | + | |
11 | +import com.hjx.parent.fragment.BaseBindingFragment; | |
12 | +import com.trello.rxlifecycle2.android.FragmentEvent; | |
13 | + | |
14 | +import io.reactivex.subjects.BehaviorSubject; | |
15 | + | |
16 | +public abstract class BaseRxFragment<VB extends ViewBinding> extends BaseBindingFragment<VB> implements ILifecycleFragment { | |
17 | + private BehaviorSubject<FragmentEvent> rxLifecycle = BehaviorSubject.create(); | |
18 | + | |
19 | + @Override | |
20 | + public BehaviorSubject<FragmentEvent> getRxLifecycle() { | |
21 | + return rxLifecycle; | |
22 | + } | |
23 | + | |
24 | + @Override | |
25 | + public void onAttach(@NonNull Context context) { | |
26 | + super.onAttach(context); | |
27 | + rxLifecycle.onNext(FragmentEvent.ATTACH); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public void onCreate(@Nullable Bundle savedInstanceState) { | |
32 | + super.onCreate(savedInstanceState); | |
33 | + rxLifecycle.onNext(FragmentEvent.CREATE); | |
34 | + } | |
35 | + | |
36 | + @Override | |
37 | + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |
38 | + super.onViewCreated(view, savedInstanceState); | |
39 | + rxLifecycle.onNext(FragmentEvent.CREATE_VIEW); | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public void onStart() { | |
44 | + super.onStart(); | |
45 | + rxLifecycle.onNext(FragmentEvent.START); | |
46 | + } | |
47 | + | |
48 | + @Override | |
49 | + public void onResume() { | |
50 | + super.onResume(); | |
51 | + rxLifecycle.onNext(FragmentEvent.RESUME); | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + public void onPause() { | |
56 | + super.onPause(); | |
57 | + rxLifecycle.onNext(FragmentEvent.PAUSE); | |
58 | + } | |
59 | + | |
60 | + @Override | |
61 | + public void onStop() { | |
62 | + super.onStop(); | |
63 | + rxLifecycle.onNext(FragmentEvent.STOP); | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + public void onDestroyView() { | |
68 | + super.onDestroyView(); | |
69 | + rxLifecycle.onNext(FragmentEvent.DESTROY_VIEW); | |
70 | + } | |
71 | + | |
72 | + @Override | |
73 | + public void onDestroy() { | |
74 | + super.onDestroy(); | |
75 | + rxLifecycle.onNext(FragmentEvent.DESTROY); | |
76 | + } | |
77 | + | |
78 | + @Override | |
79 | + public void onDetach() { | |
80 | + super.onDetach(); | |
81 | + rxLifecycle.onNext(FragmentEvent.DETACH); | |
82 | + } | |
83 | + | |
84 | +} | ... | ... |
app/src/main/java/com/hjx/parent/rx/ILifecycleActivity.java
... | ... | @@ -0,0 +1,48 @@ |
1 | +package com.hjx.parent.rx; | |
2 | + | |
3 | +import com.trello.rxlifecycle2.android.ActivityEvent; | |
4 | +import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | |
5 | + | |
6 | +import io.reactivex.Observable; | |
7 | +import io.reactivex.Observer; | |
8 | +import io.reactivex.Single; | |
9 | +import io.reactivex.SingleObserver; | |
10 | +import io.reactivex.android.schedulers.AndroidSchedulers; | |
11 | +import io.reactivex.disposables.Disposable; | |
12 | +import io.reactivex.functions.Consumer; | |
13 | +import io.reactivex.schedulers.Schedulers; | |
14 | +import retrofit2.Call; | |
15 | + | |
16 | +// 抽象 | |
17 | +public interface ILifecycleActivity { | |
18 | + Observable<ActivityEvent> getRxLifecycle(); | |
19 | + | |
20 | + default <T> Single<T> getSingleResult(Call<T> call) { | |
21 | + return Single.just(call) | |
22 | + .map(t -> t.execute().body()) | |
23 | + .subscribeOn(Schedulers.io()) | |
24 | + .observeOn(AndroidSchedulers.mainThread()) | |
25 | + .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())); | |
26 | + } | |
27 | + | |
28 | + default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { | |
29 | + single.subscribeOn(Schedulers.io()) | |
30 | + .observeOn(AndroidSchedulers.mainThread()) | |
31 | + .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | |
32 | + .subscribe(observer); | |
33 | + } | |
34 | + | |
35 | + default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { | |
36 | + observable.subscribeOn(Schedulers.io()) | |
37 | + .observeOn(AndroidSchedulers.mainThread()) | |
38 | + .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | |
39 | + .subscribe(observer); | |
40 | + } | |
41 | + | |
42 | + default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { | |
43 | + return observable.subscribeOn(Schedulers.io()) | |
44 | + .observeOn(AndroidSchedulers.mainThread()) | |
45 | + .compose(RxLifecycleAndroid.bindActivity(getRxLifecycle())) | |
46 | + .subscribe(onNext); | |
47 | + } | |
48 | +} | ... | ... |
app/src/main/java/com/hjx/parent/rx/ILifecycleFragment.java
... | ... | @@ -0,0 +1,48 @@ |
1 | +package com.hjx.parent.rx; | |
2 | + | |
3 | +import com.trello.rxlifecycle2.android.FragmentEvent; | |
4 | +import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | |
5 | + | |
6 | +import io.reactivex.Observable; | |
7 | +import io.reactivex.Observer; | |
8 | +import io.reactivex.Single; | |
9 | +import io.reactivex.SingleObserver; | |
10 | +import io.reactivex.android.schedulers.AndroidSchedulers; | |
11 | +import io.reactivex.disposables.Disposable; | |
12 | +import io.reactivex.functions.Consumer; | |
13 | +import io.reactivex.schedulers.Schedulers; | |
14 | +import retrofit2.Call; | |
15 | + | |
16 | +// 抽象 | |
17 | +public interface ILifecycleFragment { | |
18 | + Observable<FragmentEvent> getRxLifecycle(); | |
19 | + | |
20 | + default <T> Single<T> getSingleResult(Call<T> call) { | |
21 | + return Single.just(call) | |
22 | + .map(t -> t.execute().body()) | |
23 | + .subscribeOn(Schedulers.io()) | |
24 | + .observeOn(AndroidSchedulers.mainThread()) | |
25 | + .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())); | |
26 | + } | |
27 | + | |
28 | + default <T> void subscribeSingle(Single<T> single, SingleObserver<T> observer) { | |
29 | + single.subscribeOn(Schedulers.io()) | |
30 | + .observeOn(AndroidSchedulers.mainThread()) | |
31 | + .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | |
32 | + .subscribe(observer); | |
33 | + } | |
34 | + | |
35 | + default <T> void subscribeRx(Observable<T> observable, Observer<T> observer) { | |
36 | + observable.subscribeOn(Schedulers.io()) | |
37 | + .observeOn(AndroidSchedulers.mainThread()) | |
38 | + .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | |
39 | + .subscribe(observer); | |
40 | + } | |
41 | + | |
42 | + default <T> Disposable subscribeRx(Observable<T> observable, Consumer<T> onNext) { | |
43 | + return observable.subscribeOn(Schedulers.io()) | |
44 | + .observeOn(AndroidSchedulers.mainThread()) | |
45 | + .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | |
46 | + .subscribe(onNext); | |
47 | + } | |
48 | +} | ... | ... |
app/src/main/res/drawable/bg_homework.xml
app/src/main/res/drawable/bg_tab_home.xml
... | ... | @@ -0,0 +1,7 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
3 | + | |
4 | + <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"/> | |
5 | + <solid android:color="#201C90F3"/> | |
6 | + | |
7 | +</shape> | |
0 | 8 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/ic_chemistry.png
74.3 KB
app/src/main/res/drawable/ic_chinese.png
73.7 KB
app/src/main/res/drawable/ic_english.png
79.7 KB
app/src/main/res/drawable/ic_math.png
73 KB
app/src/main/res/drawable/ic_physics.png
71 KB
app/src/main/res/drawable/png_entry_error.png
205 KB
app/src/main/res/drawable/png_entry_homework.png
203 KB
app/src/main/res/drawable/shape_radius_10.xml
app/src/main/res/layout/empty_homework.xml
... | ... | @@ -0,0 +1,28 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<FrameLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + xmlns:tools="http://schemas.android.com/tools" | |
5 | + android:layout_width="match_parent" | |
6 | + android:layout_height="match_parent"> | |
7 | + <LinearLayout | |
8 | + android:id="@+id/ll_empty" | |
9 | + android:layout_width="wrap_content" | |
10 | + android:layout_height="wrap_content" | |
11 | + android:layout_gravity="center_horizontal" | |
12 | + android:orientation="vertical" | |
13 | + tools:ignore="UseCompoundDrawables,UselessParent"> | |
14 | + | |
15 | + <ImageView | |
16 | + android:layout_width="155dp" | |
17 | + android:layout_height="130dp" | |
18 | + android:src="@mipmap/ic_empty" | |
19 | + android:importantForAccessibility="no" /> | |
20 | + | |
21 | + <TextView | |
22 | + android:layout_width="wrap_content" | |
23 | + android:layout_height="wrap_content" | |
24 | + android:layout_gravity="center_horizontal" | |
25 | + android:text="暂无作业~" | |
26 | + tools:ignore="HardcodedText" /> | |
27 | + </LinearLayout> | |
28 | +</FrameLayout> | |
0 | 29 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_error_book.xml
1 | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | + xmlns:tools="http://schemas.android.com/tools" | |
2 | 3 | android:layout_width="match_parent" |
3 | 4 | android:layout_height="match_parent" |
4 | - android:orientation="vertical"> | |
5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
6 | + android:orientation="vertical" | |
7 | + tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> | |
5 | 8 | |
6 | 9 | <RelativeLayout |
7 | 10 | android:layout_width="match_parent" |
... | ... | @@ -13,26 +16,27 @@ |
13 | 16 | android:layout_width="35dp" |
14 | 17 | android:layout_height="35dp" |
15 | 18 | android:layout_centerVertical="true" |
16 | - android:layout_marginLeft="15dp" /> | |
19 | + android:layout_marginStart="15dp" /> | |
17 | 20 | |
18 | 21 | <TextView |
19 | 22 | android:id="@+id/tv_name" |
20 | 23 | android:layout_width="wrap_content" |
21 | 24 | android:layout_height="wrap_content" |
22 | 25 | android:layout_centerVertical="true" |
23 | - android:layout_marginLeft="10dp" | |
24 | - android:layout_toRightOf="@+id/iv_student" | |
26 | + android:layout_marginStart="10dp" | |
27 | + android:layout_toEndOf="@+id/iv_student" | |
25 | 28 | android:textColor="#333333" |
26 | - android:textSize="16sp" /> | |
29 | + android:textSize="16sp" | |
30 | + tools:ignore="RelativeOverlap" /> | |
27 | 31 | |
28 | - <TextView | |
32 | + <androidx.appcompat.widget.AppCompatTextView | |
29 | 33 | android:id="@+id/tv_choose" |
30 | 34 | android:layout_width="wrap_content" |
31 | 35 | android:layout_height="wrap_content" |
32 | - android:layout_alignParentRight="true" | |
36 | + android:layout_alignParentEnd="true" | |
33 | 37 | android:layout_centerVertical="true" |
34 | - android:layout_marginRight="15dp" | |
35 | - android:drawableRight="@drawable/ic_filter_black" | |
38 | + android:layout_marginEnd="15dp" | |
39 | + android:drawableEnd="@drawable/ic_filter_black" | |
36 | 40 | android:drawablePadding="5dp" |
37 | 41 | android:text="选择学生" |
38 | 42 | android:textColor="#333333" |
... | ... | @@ -40,85 +44,142 @@ |
40 | 44 | |
41 | 45 | </RelativeLayout> |
42 | 46 | |
43 | - <RelativeLayout | |
44 | - android:id="@+id/rl_take_photo" | |
47 | + <LinearLayout | |
48 | + android:orientation="horizontal" | |
49 | + android:weightSum="2" | |
45 | 50 | android:layout_width="match_parent" |
46 | - android:layout_height="200dp" | |
47 | - android:background="@mipmap/ic_take_photo"> | |
51 | + android:layout_height="wrap_content" | |
52 | + android:baselineAligned="false"> | |
53 | + <FrameLayout | |
54 | + android:id="@+id/rl_take_photo" | |
55 | + android:layout_width="0dp" | |
56 | + android:layout_weight="1" | |
57 | + android:layout_height="wrap_content"> | |
58 | + <ImageView | |
59 | + android:src="@drawable/png_entry_error" | |
60 | + android:adjustViewBounds="true" | |
61 | + android:layout_width="match_parent" | |
62 | + android:layout_height="wrap_content"/> | |
48 | 63 | |
49 | - <TextView | |
50 | - android:layout_width="wrap_content" | |
51 | - android:layout_height="wrap_content" | |
52 | - android:layout_alignParentRight="true" | |
53 | - android:layout_centerVertical="true" | |
54 | - android:layout_marginRight="70dp" | |
55 | - android:text="录入错题" | |
56 | - android:textColor="#EDF6FF" | |
57 | - android:textSize="22sp" | |
58 | - android:textStyle="bold" /> | |
59 | - </RelativeLayout> | |
64 | + <TextView | |
65 | + android:layout_width="wrap_content" | |
66 | + android:layout_height="wrap_content" | |
67 | + android:layout_gravity="center_horizontal|bottom" | |
68 | + android:layout_marginBottom="38dp" | |
69 | + android:text="录入错题" | |
70 | + android:textColor="#EDF6FF" | |
71 | + android:textSize="20sp" | |
72 | + android:textStyle="bold" /> | |
73 | + </FrameLayout> | |
74 | + | |
75 | + <FrameLayout | |
76 | + android:id="@+id/flEntryHomework" | |
77 | + android:layout_width="0dp" | |
78 | + android:layout_weight="1" | |
79 | + android:layout_height="wrap_content"> | |
80 | + <ImageView | |
81 | + android:src="@drawable/png_entry_homework" | |
82 | + android:adjustViewBounds="true" | |
83 | + android:layout_width="match_parent" | |
84 | + android:layout_height="wrap_content"/> | |
60 | 85 | |
61 | - <RelativeLayout | |
86 | + <TextView | |
87 | + android:layout_width="wrap_content" | |
88 | + android:layout_height="wrap_content" | |
89 | + android:layout_gravity="center_horizontal|bottom" | |
90 | + android:layout_marginBottom="38dp" | |
91 | + android:text="录入作业" | |
92 | + android:textColor="#EDF6FF" | |
93 | + android:textSize="20sp" | |
94 | + android:textStyle="bold" /> | |
95 | + </FrameLayout> | |
96 | + </LinearLayout> | |
97 | + | |
98 | + <LinearLayout | |
99 | + android:orientation="vertical" | |
100 | + android:background="@drawable/shape_radius_10" | |
101 | + android:backgroundTint="@color/white" | |
102 | + android:layout_marginHorizontal="15dp" | |
103 | + android:layout_marginTop="10dp" | |
104 | + android:layout_marginBottom="15dp" | |
62 | 105 | android:layout_width="match_parent" |
63 | - android:layout_height="25dp"> | |
106 | + android:layout_height="match_parent"> | |
64 | 107 | |
65 | - <TextView | |
66 | - android:layout_width="wrap_content" | |
67 | - android:layout_height="wrap_content" | |
68 | - android:layout_marginLeft="15dp" | |
69 | - android:text="最近录入错题" | |
70 | - android:textColor="#333333" | |
71 | - android:textSize="16sp" | |
72 | - android:textStyle="bold" /> | |
108 | + <com.google.android.material.tabs.TabLayout | |
109 | + android:id="@+id/tabLayout" | |
110 | + app:tabMode="fixed" | |
111 | + app:tabGravity="fill" | |
112 | + app:tabIndicatorFullWidth="false" | |
113 | + app:tabIndicatorColor="#1C90F3" | |
114 | + app:tabTextColor="#333" | |
115 | + app:tabSelectedTextColor="#1C90F3" | |
116 | + app:tabTextAppearance="@style/tab_home_item" | |
117 | + app:tabRippleColor="@color/transparent" | |
118 | + android:background="@drawable/bg_tab_home" | |
119 | + android:paddingBottom="4dp" | |
120 | + android:layout_width="match_parent" | |
121 | + android:layout_height="36dp"/> | |
73 | 122 | |
74 | - <LinearLayout | |
75 | - android:id="@+id/ll_all" | |
76 | - android:layout_width="wrap_content" | |
77 | - android:layout_height="wrap_content" | |
78 | - android:layout_alignParentRight="true" | |
79 | - android:layout_centerVertical="true" | |
80 | - android:layout_marginRight="15dp"> | |
123 | + <androidx.recyclerview.widget.RecyclerView | |
124 | + android:id="@+id/rvSubject" | |
125 | + android:orientation="horizontal" | |
126 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | |
127 | + android:layout_marginTop="15dp" | |
128 | + android:layout_width="match_parent" | |
129 | + android:layout_height="wrap_content" /> | |
81 | 130 | |
131 | + <LinearLayout | |
132 | + android:layout_marginTop="16dp" | |
133 | + android:layout_marginHorizontal="10dp" | |
134 | + android:layout_width="match_parent" | |
135 | + android:layout_height="25dp"> | |
82 | 136 | <TextView |
137 | + android:id="@+id/tvListTitle" | |
83 | 138 | android:layout_width="wrap_content" |
84 | 139 | android:layout_height="wrap_content" |
85 | - android:layout_gravity="center_vertical" | |
86 | - android:text="查看全部" | |
87 | - android:textColor="#666666" | |
88 | - android:textSize="12sp" /> | |
89 | - | |
90 | - <ImageView | |
91 | - android:layout_width="9dp" | |
92 | - android:layout_height="10dp" | |
93 | - android:layout_gravity="center_vertical" | |
94 | - android:layout_marginLeft="5dp" | |
95 | - android:src="@mipmap/ic_arrow_right" /> | |
96 | - </LinearLayout> | |
97 | - </RelativeLayout> | |
140 | + android:text="最近录入错题" | |
141 | + android:textColor="#333333" | |
142 | + android:textSize="16sp" | |
143 | + android:textStyle="bold" /> | |
98 | 144 | |
99 | - <androidx.recyclerview.widget.RecyclerView | |
100 | - android:id="@+id/recycle_subject" | |
101 | - android:layout_width="match_parent" | |
102 | - android:layout_height="wrap_content" | |
103 | - android:layout_marginLeft="15dp" | |
104 | - android:layout_marginTop="15dp" | |
105 | - android:layout_marginRight="15dp" /> | |
145 | + <Space style="@style/empty_space"/> | |
106 | 146 | |
107 | - <RelativeLayout | |
108 | - android:layout_width="match_parent" | |
109 | - android:layout_height="match_parent"> | |
147 | + <LinearLayout | |
148 | + android:id="@+id/ll_all" | |
149 | + android:layout_width="wrap_content" | |
150 | + android:layout_height="wrap_content" | |
151 | + android:layout_gravity="center_vertical"> | |
152 | + | |
153 | + <TextView | |
154 | + android:layout_width="wrap_content" | |
155 | + android:layout_height="wrap_content" | |
156 | + android:layout_gravity="center_vertical" | |
157 | + android:text="查看全部" | |
158 | + android:textColor="#666666" | |
159 | + android:textSize="12sp" /> | |
160 | + | |
161 | + <ImageView | |
162 | + android:layout_width="9dp" | |
163 | + android:layout_height="10dp" | |
164 | + android:layout_gravity="center_vertical" | |
165 | + android:layout_marginStart="5dp" | |
166 | + android:src="@mipmap/ic_arrow_right" /> | |
167 | + </LinearLayout> | |
168 | + </LinearLayout> | |
110 | 169 | |
111 | 170 | <androidx.recyclerview.widget.RecyclerView |
112 | - android:id="@+id/recycle_error" | |
171 | + android:id="@+id/rvMain" | |
172 | + android:orientation="vertical" | |
173 | + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | |
113 | 174 | android:layout_width="match_parent" |
114 | - android:layout_height="wrap_content" | |
175 | + android:layout_height="match_parent" | |
115 | 176 | android:layout_marginTop="15dp" /> |
116 | 177 | |
117 | 178 | <LinearLayout |
118 | 179 | android:id="@+id/ll_empty" |
119 | 180 | android:layout_width="wrap_content" |
120 | 181 | android:layout_height="wrap_content" |
121 | - android:layout_centerHorizontal="true" | |
182 | + android:layout_gravity="center_horizontal" | |
122 | 183 | android:layout_marginTop="30dp" |
123 | 184 | android:orientation="vertical" |
124 | 185 | android:visibility="gone"> |
... | ... | @@ -134,7 +195,6 @@ |
134 | 195 | android:layout_gravity="center_horizontal" |
135 | 196 | android:text="暂无错题~" /> |
136 | 197 | </LinearLayout> |
137 | - </RelativeLayout> | |
138 | - | |
139 | 198 | |
199 | + </LinearLayout> | |
140 | 200 | </LinearLayout> |
141 | 201 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item_homework.xml
... | ... | @@ -0,0 +1,70 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
5 | + xmlns:tools="http://schemas.android.com/tools" | |
6 | + android:orientation="vertical" | |
7 | + android:paddingHorizontal="10dp" | |
8 | + android:layout_marginVertical="8dp" | |
9 | + android:layout_width="match_parent" | |
10 | + android:layout_height="wrap_content" | |
11 | + tools:ignore="SmallSp"> | |
12 | + | |
13 | + <TextView | |
14 | + android:id="@+id/tvDate" | |
15 | + android:visibility="gone" | |
16 | + tools:visibility="visible" | |
17 | + tools:text="2024-09-25" | |
18 | + android:textSize="12sp" | |
19 | + android:textColor="#999" | |
20 | + android:layout_marginBottom="15dp" | |
21 | + android:layout_width="wrap_content" | |
22 | + android:layout_height="wrap_content"/> | |
23 | + | |
24 | + <LinearLayout | |
25 | + android:orientation="horizontal" | |
26 | + android:gravity="center_vertical" | |
27 | + android:background="@drawable/bg_homework" | |
28 | + android:layout_width="match_parent" | |
29 | + android:layout_height="75dp"> | |
30 | + <ImageView | |
31 | + android:id="@+id/ivSubject" | |
32 | + tools:src="@drawable/ic_math" | |
33 | + android:layout_marginStart="10dp" | |
34 | + android:layout_width="44dp" | |
35 | + android:layout_height="56dp" | |
36 | + android:importantForAccessibility="no" /> | |
37 | + <LinearLayout | |
38 | + android:orientation="vertical" | |
39 | + android:layout_marginStart="14dp" | |
40 | + android:layout_marginVertical="16dp" | |
41 | + android:layout_width="wrap_content" | |
42 | + android:layout_height="match_parent"> | |
43 | + <TextView | |
44 | + android:id="@+id/tvName" | |
45 | + tools:text="作业名称" | |
46 | + android:textSize="13sp" | |
47 | + android:textColor="#333" | |
48 | + android:layout_width="wrap_content" | |
49 | + android:layout_height="wrap_content"/> | |
50 | + <Space style="@style/empty_space"/> | |
51 | + <TextView | |
52 | + android:id="@+id/tvGrade" | |
53 | + tools:text="七年级-上学期" | |
54 | + android:textSize="10sp" | |
55 | + android:textColor="#666" | |
56 | + android:layout_width="wrap_content" | |
57 | + android:layout_height="wrap_content" /> | |
58 | + </LinearLayout> | |
59 | + <Space style="@style/empty_space"/> | |
60 | + <TextView | |
61 | + android:text=">" | |
62 | + android:textSize="20sp" | |
63 | + android:textColor="#333" | |
64 | + android:layout_marginEnd="10dp" | |
65 | + android:layout_width="wrap_content" | |
66 | + android:layout_height="wrap_content" | |
67 | + tools:ignore="HardcodedText" /> | |
68 | + </LinearLayout> | |
69 | + | |
70 | +</LinearLayout> | |
0 | 71 | \ No newline at end of file | ... | ... |
app/src/main/res/values/appearance.xml
app/src/main/res/values/styles.xml
... | ... | @@ -53,5 +53,10 @@ |
53 | 53 | <item name="android:textSize">15sp</item> |
54 | 54 | </style> |
55 | 55 | |
56 | + <style name="empty_space"> | |
57 | + <item name="android:layout_width">0dp</item> | |
58 | + <item name="android:layout_height">0dp</item> | |
59 | + <item name="android:layout_weight">1</item> | |
60 | + </style> | |
56 | 61 | |
57 | 62 | </resources> |
58 | 63 | \ No newline at end of file | ... | ... |
libs/common/src/main/java/com/prws/common/bean/homework/HomeworkList.java
... | ... | @@ -0,0 +1,90 @@ |
1 | +package com.prws.common.bean.homework; | |
2 | + | |
3 | +import com.google.gson.annotations.SerializedName; | |
4 | + | |
5 | +import java.util.Date; | |
6 | + | |
7 | +public class HomeworkList { | |
8 | + | |
9 | + @SerializedName(value = "homeworkId", alternate = "id") | |
10 | + private Integer homeworkId; | |
11 | + @SerializedName(value = "name", alternate = "homeworkName") | |
12 | + private String name; | |
13 | + @SerializedName("grade") | |
14 | + private String grade; | |
15 | + @SerializedName("term") | |
16 | + private String term; | |
17 | + @SerializedName("subject") | |
18 | + private String subject; | |
19 | + private int completeFlag; | |
20 | + | |
21 | + private Integer total; | |
22 | + private Integer right; | |
23 | + | |
24 | + public Date uploadTime; | |
25 | + | |
26 | + public Integer getTotal() { | |
27 | + return total; | |
28 | + } | |
29 | + | |
30 | + public Integer getRight() { | |
31 | + return right; | |
32 | + } | |
33 | + | |
34 | + public void setRight(Integer right) { | |
35 | + this.right = right; | |
36 | + } | |
37 | + | |
38 | + public void setTotal(Integer total) { | |
39 | + this.total = total; | |
40 | + } | |
41 | + | |
42 | + public void setId(Integer id) { | |
43 | + this.homeworkId = id; | |
44 | + } | |
45 | + | |
46 | + public void setName(String name) { | |
47 | + this.name = name; | |
48 | + } | |
49 | + | |
50 | + public void setGrade(String grade) { | |
51 | + this.grade = grade; | |
52 | + } | |
53 | + | |
54 | + public void setTerm(String term) { | |
55 | + this.term = term; | |
56 | + } | |
57 | + | |
58 | + public void setSubject(String subject) { | |
59 | + this.subject = subject; | |
60 | + } | |
61 | + | |
62 | + public void setCompleteFlag(int completeFlag) { | |
63 | + this.completeFlag = completeFlag; | |
64 | + } | |
65 | + | |
66 | + public Integer getId() { | |
67 | + return homeworkId; | |
68 | + } | |
69 | + | |
70 | + public String getName() { | |
71 | + return name; | |
72 | + } | |
73 | + | |
74 | + public String getGrade() { | |
75 | + return grade; | |
76 | + } | |
77 | + | |
78 | + public String getTerm() { | |
79 | + return term; | |
80 | + } | |
81 | + | |
82 | + public String getSubject() { | |
83 | + return subject; | |
84 | + } | |
85 | + | |
86 | + public int getCompleteFlag() { | |
87 | + return completeFlag; | |
88 | + } | |
89 | + | |
90 | +} | ... | ... |
libs/common/src/main/java/com/prws/common/net/NetWorks.java
... | ... | @@ -4,7 +4,6 @@ package com.prws.common.net; |
4 | 4 | import com.google.gson.Gson; |
5 | 5 | import com.google.gson.JsonObject; |
6 | 6 | import com.prws.common.BuildConfig; |
7 | -import com.prws.common.bean.BaseEntity; | |
8 | 7 | import com.prws.common.bean.CutPicBean; |
9 | 8 | import com.prws.common.bean.GradeAndSubject; |
10 | 9 | import com.prws.common.bean.PageInfo; |
... | ... | @@ -13,6 +12,7 @@ import com.prws.common.bean.ScheduleBean; |
13 | 12 | import com.prws.common.bean.Teacher; |
14 | 13 | import com.prws.common.bean.TopicBean; |
15 | 14 | import com.prws.common.bean.UpdateBean; |
15 | +import com.prws.common.bean.homework.HomeworkList; | |
16 | 16 | import com.prws.common.utils.SharedPreferencesUtil; |
17 | 17 | |
18 | 18 | import java.io.File; |
... | ... | @@ -22,6 +22,7 @@ import java.util.Map; |
22 | 22 | |
23 | 23 | import io.reactivex.Observable; |
24 | 24 | import io.reactivex.Observer; |
25 | +import io.reactivex.Single; | |
25 | 26 | import io.reactivex.android.schedulers.AndroidSchedulers; |
26 | 27 | import io.reactivex.schedulers.Schedulers; |
27 | 28 | import okhttp3.MediaType; |
... | ... | @@ -31,22 +32,15 @@ import okhttp3.ResponseBody; |
31 | 32 | import retrofit2.Call; |
32 | 33 | import retrofit2.Callback; |
33 | 34 | import retrofit2.http.Body; |
34 | -import retrofit2.http.DELETE; | |
35 | -import retrofit2.http.FieldMap; | |
36 | -import retrofit2.http.FormUrlEncoded; | |
37 | 35 | import retrofit2.http.GET; |
38 | 36 | import retrofit2.http.Header; |
39 | -import retrofit2.http.HeaderMap; | |
40 | 37 | import retrofit2.http.Headers; |
41 | 38 | import retrofit2.http.Multipart; |
42 | 39 | import retrofit2.http.POST; |
43 | 40 | import retrofit2.http.PUT; |
44 | 41 | import retrofit2.http.Part; |
45 | 42 | import retrofit2.http.PartMap; |
46 | -import retrofit2.http.Path; | |
47 | 43 | import retrofit2.http.Query; |
48 | -import retrofit2.http.QueryMap; | |
49 | -import retrofit2.http.Streaming; | |
50 | 44 | import retrofit2.http.Url; |
51 | 45 | |
52 | 46 | /** |
... | ... | @@ -67,7 +61,7 @@ public class NetWorks extends RetrofitUtils { |
67 | 61 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; |
68 | 62 | |
69 | 63 | |
70 | - private interface NetService { | |
64 | + public interface NetService { | |
71 | 65 | |
72 | 66 | |
73 | 67 | @GET("/api/v1/user/logout") |
... | ... | @@ -178,6 +172,10 @@ public class NetWorks extends RetrofitUtils { |
178 | 172 | |
179 | 173 | @GET("api/v1/answer/listRecordForTeacher") |
180 | 174 | Observable<ResponseBody> getRecordList(@Header("Authorization") String token, @Query("userId") String id); |
175 | + | |
176 | + @GET("api/v1/homework/listHomeworkByStuId") | |
177 | + Single<ResponseResult<List<HomeworkList>>> getStudentHomework(@Header("Authorization") String token, @Query("stuId") String stuId); | |
178 | + | |
181 | 179 | } |
182 | 180 | |
183 | 181 | ... | ... |