Commit a9477a8164c0172013cee7aed576b480d2fdb0c6
1 parent
4e0766ff73
Exists in
master
首页优化
Showing
2 changed files
with
7 additions
and
7 deletions
Show diff stats
app/src/main/java/com/hjx/parent/fragment/ErrorFragment.java
1 | package com.hjx.parent.fragment; | 1 | package com.hjx.parent.fragment; |
2 | 2 | ||
3 | import static android.app.Activity.RESULT_OK; | 3 | import static android.app.Activity.RESULT_OK; |
4 | 4 | ||
5 | import android.annotation.SuppressLint; | 5 | import android.annotation.SuppressLint; |
6 | import android.content.Intent; | 6 | import android.content.Intent; |
7 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
8 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
9 | import android.net.Uri; | 9 | import android.net.Uri; |
10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
11 | import android.provider.MediaStore; | 11 | import android.provider.MediaStore; |
12 | import android.text.TextUtils; | 12 | import android.text.TextUtils; |
13 | import android.util.Log; | 13 | import android.util.Log; |
14 | import android.view.LayoutInflater; | 14 | import android.view.LayoutInflater; |
15 | import android.view.View; | 15 | import android.view.View; |
16 | import android.view.ViewGroup; | 16 | import android.view.ViewGroup; |
17 | import android.widget.Toast; | 17 | import android.widget.Toast; |
18 | 18 | ||
19 | import androidx.annotation.NonNull; | 19 | import androidx.annotation.NonNull; |
20 | import androidx.annotation.Nullable; | 20 | import androidx.annotation.Nullable; |
21 | import androidx.core.content.FileProvider; | 21 | import androidx.core.content.FileProvider; |
22 | import androidx.recyclerview.widget.RecyclerView; | 22 | import androidx.recyclerview.widget.RecyclerView; |
23 | 23 | ||
24 | import com.bumptech.glide.Glide; | 24 | import com.bumptech.glide.Glide; |
25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | 25 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
26 | import com.bumptech.glide.request.RequestOptions; | 26 | import com.bumptech.glide.request.RequestOptions; |
27 | import com.chad.library.adapter.base.BaseQuickAdapter; | 27 | import com.chad.library.adapter.base.BaseQuickAdapter; |
28 | import com.chad.library.adapter.base.BaseViewHolder; | 28 | import com.chad.library.adapter.base.BaseViewHolder; |
29 | import com.google.android.material.tabs.TabLayout; | 29 | import com.google.android.material.tabs.TabLayout; |
30 | import com.google.gson.Gson; | 30 | import com.google.gson.Gson; |
31 | import com.hjq.permissions.OnPermissionCallback; | 31 | import com.hjq.permissions.OnPermissionCallback; |
32 | import com.hjq.permissions.Permission; | 32 | import com.hjq.permissions.Permission; |
33 | import com.hjq.permissions.XXPermissions; | 33 | import com.hjq.permissions.XXPermissions; |
34 | import com.hjx.parent.ErrorListActivity; | 34 | import com.hjx.parent.ErrorListActivity; |
35 | import com.hjx.parent.ImageActivity; | 35 | import com.hjx.parent.ImageActivity; |
36 | import com.hjx.parent.R; | 36 | import com.hjx.parent.R; |
37 | import com.hjx.parent.StuHomeworkActivity; | 37 | import com.hjx.parent.StuHomeworkActivity; |
38 | import com.hjx.parent.TeacherChooseActivity; | 38 | import com.hjx.parent.TeacherChooseActivity; |
39 | import com.hjx.parent.adapter.ErrorAdapter; | 39 | import com.hjx.parent.adapter.ErrorAdapter; |
40 | import com.hjx.parent.adapter.HomeworkAdapter; | 40 | import com.hjx.parent.adapter.HomeworkAdapter; |
41 | import com.hjx.parent.bean.StudentBean; | 41 | import com.hjx.parent.bean.StudentBean; |
42 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 42 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
43 | import com.hjx.parent.rx.BaseRxFragment; | 43 | import com.hjx.parent.rx.BaseRxFragment; |
44 | import com.prws.common.bean.PageInfo; | 44 | import com.prws.common.bean.PageInfo; |
45 | import com.prws.common.bean.ResponseResult; | 45 | import com.prws.common.bean.ResponseResult; |
46 | import com.prws.common.bean.TopicBean; | 46 | import com.prws.common.bean.TopicBean; |
47 | import com.prws.common.net.NetWorks; | 47 | import com.prws.common.net.NetWorks; |
48 | import com.prws.common.utils.BitmapUtils; | 48 | import com.prws.common.utils.BitmapUtils; |
49 | import com.prws.common.utils.CommonUtil; | 49 | import com.prws.common.utils.CommonUtil; |
50 | import com.prws.common.utils.ScreenUtils; | 50 | import com.prws.common.utils.ScreenUtils; |
51 | import com.prws.common.utils.SharedPreferencesUtil; | 51 | import com.prws.common.utils.SharedPreferencesUtil; |
52 | import com.prws.common.utils.dialog.MyButtomDialog; | 52 | import com.prws.common.utils.dialog.MyButtomDialog; |
53 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 53 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
54 | import com.zhangteng.imagepicker.bean.ImageInfo; | 54 | import com.zhangteng.imagepicker.bean.ImageInfo; |
55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 55 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 56 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 57 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 58 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
59 | import com.zhangteng.utils.IHandlerCallBack; | 59 | import com.zhangteng.utils.IHandlerCallBack; |
60 | 60 | ||
61 | import java.io.File; | 61 | import java.io.File; |
62 | import java.util.ArrayList; | 62 | import java.util.ArrayList; |
63 | import java.util.Arrays; | 63 | import java.util.Arrays; |
64 | import java.util.Collections; | 64 | import java.util.Collections; |
65 | import java.util.HashMap; | 65 | import java.util.HashMap; |
66 | import java.util.List; | 66 | import java.util.List; |
67 | import java.util.Map; | 67 | import java.util.Map; |
68 | 68 | ||
69 | import io.reactivex.Observable; | 69 | import io.reactivex.Observable; |
70 | import io.reactivex.Observer; | 70 | import io.reactivex.Observer; |
71 | import io.reactivex.android.schedulers.AndroidSchedulers; | 71 | import io.reactivex.android.schedulers.AndroidSchedulers; |
72 | import io.reactivex.disposables.Disposable; | 72 | import io.reactivex.disposables.Disposable; |
73 | import io.reactivex.schedulers.Schedulers; | 73 | import io.reactivex.schedulers.Schedulers; |
74 | 74 | ||
75 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 75 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
76 | StudentBean studentBean; | 76 | StudentBean studentBean; |
77 | private int subject; | 77 | private int subject; |
78 | private ErrorAdapter errorAdapter; | 78 | private ErrorAdapter errorAdapter; |
79 | private HomeworkAdapter homeworkAdapter; | 79 | private HomeworkAdapter homeworkAdapter; |
80 | private String filePath; | 80 | private String filePath; |
81 | 81 | ||
82 | @Override | 82 | @Override |
83 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 83 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
84 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 84 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
85 | } | 85 | } |
86 | 86 | ||
87 | public void refreshStudent() { | 87 | public void refreshStudent() { |
88 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 88 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
89 | try { | 89 | try { |
90 | studentBean = new Gson().fromJson(student, StudentBean.class); | 90 | studentBean = new Gson().fromJson(student, StudentBean.class); |
91 | getBinding().tvChoose.setText(studentBean.getStuName()); | 91 | getBinding().tvChoose.setText(studentBean.getStuName()); |
92 | } catch (Exception e) { | 92 | } catch (Exception e) { |
93 | e.printStackTrace(); | 93 | e.printStackTrace(); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 98 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
99 | super.onViewCreated(view, savedInstanceState); | 99 | super.onViewCreated(view, savedInstanceState); |
100 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 100 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
101 | if (!TextUtils.isEmpty(photo)) { | 101 | if (!TextUtils.isEmpty(photo)) { |
102 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 102 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
103 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 103 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
104 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 104 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
105 | } | 105 | } |
106 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 106 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
107 | getBinding().tvName.setText(name); | 107 | getBinding().tvName.setText(name); |
108 | refreshStudent(); | 108 | refreshStudent(); |
109 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 109 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
110 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 110 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
111 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 111 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
112 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 112 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
113 | @Override | 113 | @Override |
114 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 114 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
115 | 115 | ||
116 | } | 116 | } |
117 | 117 | ||
118 | @Override | 118 | @Override |
119 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 119 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
120 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 120 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
121 | switch (item.getAdapterPosition()) { | 121 | switch (item.getAdapterPosition()) { |
122 | case 0: | 122 | case 0: |
123 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 123 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
124 | break; | 124 | break; |
125 | case 1: | 125 | case 1: |
126 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 126 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
127 | break; | 127 | break; |
128 | case 2: | 128 | case 2: |
129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
130 | break; | 130 | break; |
131 | case 3: | 131 | case 3: |
132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
133 | break; | 133 | break; |
134 | case 4: | 134 | case 4: |
135 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 135 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 138 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
139 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 139 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
140 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 140 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
141 | item.getConvertView().setOnClickListener(v -> { | 141 | item.getConvertView().setOnClickListener(v -> { |
142 | if (subject != item.getAdapterPosition()) { | 142 | if (subject != item.getAdapterPosition()) { |
143 | subject = item.getAdapterPosition(); | 143 | subject = item.getAdapterPosition(); |
144 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 144 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
145 | getError(subStr); | 145 | getError(subStr); |
146 | getHomework(subStr); | 146 | getHomework(subStr); |
147 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | ||
148 | binding.tvListTitle.setText("最近错题"); | ||
149 | } else { | ||
150 | binding.tvListTitle.setText("最近作业"); | ||
151 | } | ||
152 | } | 147 | } |
153 | }); | 148 | }); |
154 | } | 149 | } |
155 | }; | 150 | }; |
156 | getBinding().rvSubject.setAdapter(adapter); | 151 | getBinding().rvSubject.setAdapter(adapter); |
157 | subject = 0; | 152 | subject = 0; |
158 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
159 | getBinding().llAll.setOnClickListener(v -> { | 154 | getBinding().llAll.setOnClickListener(v -> { |
160 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 155 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
161 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 156 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
162 | startActivity(intent); | 157 | startActivity(intent); |
163 | } else { | 158 | } else { |
164 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | 159 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); |
165 | startActivity(intent); | 160 | startActivity(intent); |
166 | } | 161 | } |
167 | }); | 162 | }); |
168 | 163 | ||
169 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 164 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
170 | homeworkAdapter = new HomeworkAdapter(); | 165 | homeworkAdapter = new HomeworkAdapter(); |
171 | binding.rvMain.setAdapter(errorAdapter); | 166 | binding.rvMain.setAdapter(errorAdapter); |
172 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 167 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
173 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 168 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
174 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 169 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
175 | @Override | 170 | @Override |
176 | public void onTabSelected(TabLayout.Tab tab) { | 171 | public void onTabSelected(TabLayout.Tab tab) { |
177 | if (tab.getPosition() == 0) { | 172 | if (tab.getPosition() == 0) { |
178 | binding.rvMain.setAdapter(errorAdapter); | 173 | binding.rvMain.setAdapter(errorAdapter); |
179 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 174 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
180 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 175 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
176 | binding.tvListTitle.setText("最近错题"); | ||
177 | binding.tvEmpty.setText("暂无错题~"); | ||
181 | } else { | 178 | } else { |
182 | binding.rvMain.setAdapter(homeworkAdapter); | 179 | binding.rvMain.setAdapter(homeworkAdapter); |
183 | binding.rvMain.setVisibility(View.VISIBLE); | 180 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); |
184 | binding.llEmpty.setVisibility(View.GONE); | 181 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); |
182 | binding.tvListTitle.setText("最近作业"); | ||
183 | binding.tvEmpty.setText("暂无作业~"); | ||
185 | } | 184 | } |
186 | } | 185 | } |
187 | @Override | 186 | @Override |
188 | public void onTabUnselected(TabLayout.Tab tab) { | 187 | public void onTabUnselected(TabLayout.Tab tab) { |
189 | } | 188 | } |
190 | @Override | 189 | @Override |
191 | public void onTabReselected(TabLayout.Tab tab) { | 190 | public void onTabReselected(TabLayout.Tab tab) { |
192 | } | 191 | } |
193 | }); | 192 | }); |
194 | } | 193 | } |
195 | 194 | ||
196 | private void takePhoto(int type) { | 195 | private void takePhoto(int type) { |
197 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 196 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
198 | XXPermissions.with(getContext()) | 197 | XXPermissions.with(getContext()) |
199 | // 申请多个权限 | 198 | // 申请多个权限 |
200 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 199 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
201 | @Override | 200 | @Override |
202 | public void onGranted(List<String> permissions, boolean all) { | 201 | public void onGranted(List<String> permissions, boolean all) { |
203 | if (all) { | 202 | if (all) { |
204 | //开启扫码界面 | 203 | //开启扫码界面 |
205 | showButtonDialog(type); | 204 | showButtonDialog(type); |
206 | } else { | 205 | } else { |
207 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 206 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
208 | } | 207 | } |
209 | } | 208 | } |
210 | 209 | ||
211 | @Override | 210 | @Override |
212 | public void onDenied(List<String> permissions, boolean never) { | 211 | public void onDenied(List<String> permissions, boolean never) { |
213 | XXPermissions.startPermissionActivity(getContext(), permissions); | 212 | XXPermissions.startPermissionActivity(getContext(), permissions); |
214 | } | 213 | } |
215 | }); | 214 | }); |
216 | } else { | 215 | } else { |
217 | showButtonDialog(type); | 216 | showButtonDialog(type); |
218 | } | 217 | } |
219 | } | 218 | } |
220 | 219 | ||
221 | private void showButtonDialog(int type) { | 220 | private void showButtonDialog(int type) { |
222 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 221 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
223 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 222 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
224 | dialog.setContentView(bottomView); | 223 | dialog.setContentView(bottomView); |
225 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 224 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
226 | @Override | 225 | @Override |
227 | public void onClick(View view) { | 226 | public void onClick(View view) { |
228 | dialog.dismiss(); | 227 | dialog.dismiss(); |
229 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 228 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
230 | //确保有相机来处理Intent | 229 | //确保有相机来处理Intent |
231 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 230 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
232 | File photoFile = new File(filePath); | 231 | File photoFile = new File(filePath); |
233 | 232 | ||
234 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 233 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
235 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 234 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
236 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 235 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
237 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 236 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
238 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 237 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
239 | } | 238 | } |
240 | }); | 239 | }); |
241 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 240 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
242 | @Override | 241 | @Override |
243 | public void onClick(View view) { | 242 | public void onClick(View view) { |
244 | dialog.dismiss(); | 243 | dialog.dismiss(); |
245 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 244 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
246 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 245 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
247 | .multiSelect(true) //是否多选 | 246 | .multiSelect(true) //是否多选 |
248 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 247 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
249 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 248 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
250 | .maxImageSelectable(5) //图片可选择数 | 249 | .maxImageSelectable(5) //图片可选择数 |
251 | .maxHeight(1920) //图片最大高度 | 250 | .maxHeight(1920) //图片最大高度 |
252 | .maxWidth(1920) //图片最大宽度 | 251 | .maxWidth(1920) //图片最大宽度 |
253 | .maxImageSize(3) //图片最大大小Mb | 252 | .maxImageSize(3) //图片最大大小Mb |
254 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | 253 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); |
255 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 254 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
256 | 255 | ||
257 | } | 256 | } |
258 | }); | 257 | }); |
259 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 258 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
260 | @Override | 259 | @Override |
261 | public void onClick(View view) { | 260 | public void onClick(View view) { |
262 | dialog.dismiss(); | 261 | dialog.dismiss(); |
263 | } | 262 | } |
264 | }); | 263 | }); |
265 | dialog.show(); | 264 | dialog.show(); |
266 | } | 265 | } |
267 | 266 | ||
268 | @SuppressLint("CheckResult") | 267 | @SuppressLint("CheckResult") |
269 | protected void getHomework(String subject) { | 268 | protected void getHomework(String subject) { |
270 | if (studentBean == null) return; | 269 | if (studentBean == null) return; |
271 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 270 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
272 | .subscribeOn(Schedulers.io()) | 271 | .subscribeOn(Schedulers.io()) |
273 | .observeOn(AndroidSchedulers.mainThread()) | 272 | .observeOn(AndroidSchedulers.mainThread()) |
274 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 273 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
275 | .map(ResponseResult::getData) | 274 | .map(ResponseResult::getData) |
276 | .toObservable() | 275 | .toObservable() |
277 | .flatMap(Observable::fromIterable) | 276 | .flatMap(Observable::fromIterable) |
278 | .filter(data -> subject.equals(data.getSubject())) | 277 | .filter(data -> subject.equals(data.getSubject())) |
279 | .toList() | 278 | .toList() |
280 | .subscribe((data, th) -> { | 279 | .subscribe((data, th) -> { |
281 | if (th != null) th.printStackTrace(); | 280 | if (th != null) th.printStackTrace(); |
282 | if (data != null) { | 281 | if (data != null) { |
283 | Collections.sort(data); | 282 | Collections.sort(data); |
284 | } | 283 | } |
285 | homeworkAdapter.setNewData(data); | 284 | homeworkAdapter.setNewData(data); |
286 | }); | 285 | }); |
287 | } | 286 | } |
288 | 287 | ||
289 | private void getError(String subject) { | 288 | private void getError(String subject) { |
290 | if (studentBean == null) { | 289 | if (studentBean == null) { |
291 | return; | 290 | return; |
292 | } | 291 | } |
293 | Map<String, Object> map = new HashMap<>(); | 292 | Map<String, Object> map = new HashMap<>(); |
294 | map.put("subject", subject); | 293 | map.put("subject", subject); |
295 | map.put("stuId", studentBean.getStuId()); | 294 | map.put("stuId", studentBean.getStuId()); |
296 | map.put("pageSize", 5); | 295 | map.put("pageSize", 5); |
297 | map.put("pageNum", 1); | 296 | map.put("pageNum", 1); |
298 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 297 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
299 | @Override | 298 | @Override |
300 | public void onSubscribe(Disposable d) { | 299 | public void onSubscribe(Disposable d) { |
301 | } | 300 | } |
302 | @Override | 301 | @Override |
303 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 302 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
304 | if (result.getData() != null && result.getCode() == 200) { | 303 | if (result.getData() != null && result.getCode() == 200) { |
305 | List<TopicBean> topicBeans = result.getData().getList(); | 304 | List<TopicBean> topicBeans = result.getData().getList(); |
306 | errorAdapter.refresh(topicBeans); | 305 | errorAdapter.refresh(topicBeans); |
307 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 306 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
308 | if (topicBeans.size() > 0) { | 307 | if (topicBeans.size() > 0) { |
309 | getBinding().rvMain.setVisibility(View.VISIBLE); | 308 | getBinding().rvMain.setVisibility(View.VISIBLE); |
310 | getBinding().llEmpty.setVisibility(View.GONE); | 309 | getBinding().llEmpty.setVisibility(View.GONE); |
311 | } else { | 310 | } else { |
312 | getBinding().rvMain.setVisibility(View.GONE); | 311 | getBinding().rvMain.setVisibility(View.GONE); |
313 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 312 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
314 | } | 313 | } |
315 | } | 314 | } |
316 | } | 315 | } |
317 | } | 316 | } |
318 | @Override | 317 | @Override |
319 | public void onError(Throwable e) { | 318 | public void onError(Throwable e) { |
320 | e.printStackTrace(); | 319 | e.printStackTrace(); |
321 | } | 320 | } |
322 | @Override | 321 | @Override |
323 | public void onComplete() { | 322 | public void onComplete() { |
324 | } | 323 | } |
325 | }); | 324 | }); |
326 | } | 325 | } |
327 | 326 | ||
328 | @Override | 327 | @Override |
329 | public void onResume() { | 328 | public void onResume() { |
330 | super.onResume(); | 329 | super.onResume(); |
331 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 330 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
332 | getError(subStr); | 331 | getError(subStr); |
333 | getHomework(subStr); | 332 | getHomework(subStr); |
334 | } | 333 | } |
335 | 334 | ||
336 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 335 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
337 | int type; | 336 | int type; |
338 | public HandlerCallBack(int type) { | 337 | public HandlerCallBack(int type) { |
339 | this.type = type; | 338 | this.type = type; |
340 | } | 339 | } |
341 | 340 | ||
342 | private String TAG = "---ImagePicker---"; | 341 | private String TAG = "---ImagePicker---"; |
343 | List<ImageInfo> photoList = new ArrayList<>(); | 342 | List<ImageInfo> photoList = new ArrayList<>(); |
344 | 343 | ||
345 | @Override | 344 | @Override |
346 | public void onStart() { | 345 | public void onStart() { |
347 | Log.i(TAG, "onStart: 开启"); | 346 | Log.i(TAG, "onStart: 开启"); |
348 | } | 347 | } |
349 | 348 | ||
350 | @Override | 349 | @Override |
351 | public void onSuccess(List<ImageInfo> photoList) { | 350 | public void onSuccess(List<ImageInfo> photoList) { |
352 | this.photoList = photoList; | 351 | this.photoList = photoList; |
353 | Log.i(TAG, "onSuccess: 返回数据"); | 352 | Log.i(TAG, "onSuccess: 返回数据"); |
354 | } | 353 | } |
355 | 354 | ||
356 | @Override | 355 | @Override |
357 | public void onCancel() { | 356 | public void onCancel() { |
358 | Log.i(TAG, "onCancel: 取消"); | 357 | Log.i(TAG, "onCancel: 取消"); |
359 | } | 358 | } |
360 | 359 | ||
361 | @Override | 360 | @Override |
362 | public void onFinish(List<ImageInfo> selectImage) { | 361 | public void onFinish(List<ImageInfo> selectImage) { |
363 | if (selectImage.size() == photoList.size()) { | 362 | if (selectImage.size() == photoList.size()) { |
364 | ArrayList<String> strings = new ArrayList<>(); | 363 | ArrayList<String> strings = new ArrayList<>(); |
365 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 364 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
366 | for (ImageInfo imageInfo : selectImage) { | 365 | for (ImageInfo imageInfo : selectImage) { |
367 | strings.add(imageInfo.getPath()); | 366 | strings.add(imageInfo.getPath()); |
368 | } | 367 | } |
369 | intent.putStringArrayListExtra("images", strings); | 368 | intent.putStringArrayListExtra("images", strings); |
370 | intent.putExtra("type", type); | 369 | intent.putExtra("type", type); |
371 | startActivity(intent); | 370 | startActivity(intent); |
372 | } | 371 | } |
373 | } | 372 | } |
374 | 373 | ||
375 | @Override | 374 | @Override |
376 | public void onError() { | 375 | public void onError() { |
377 | Log.i(TAG, "onError: 出错"); | 376 | Log.i(TAG, "onError: 出错"); |
378 | } | 377 | } |
379 | } | 378 | } |
380 | 379 | ||
381 | @Override | 380 | @Override |
382 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 381 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
383 | super.onActivityResult(requestCode, resultCode, data); | 382 | super.onActivityResult(requestCode, resultCode, data); |
384 | if (resultCode != RESULT_OK) return; | 383 | if (resultCode != RESULT_OK) return; |
385 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 384 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
386 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 385 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
387 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 386 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
388 | CommonUtil.saveBitmapToUri(b, path); | 387 | CommonUtil.saveBitmapToUri(b, path); |
389 | ArrayList<String> strings = new ArrayList<>(); | 388 | ArrayList<String> strings = new ArrayList<>(); |
390 | Intent intent = new Intent(getContext(), ImageActivity.class); | 389 | Intent intent = new Intent(getContext(), ImageActivity.class); |
391 | strings.add(path); | 390 | strings.add(path); |
392 | intent.putStringArrayListExtra("images", strings); | 391 | intent.putStringArrayListExtra("images", strings); |
393 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 392 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
394 | startActivity(intent); | 393 | startActivity(intent); |
app/src/main/res/layout/fragment_error_book.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | xmlns:tools="http://schemas.android.com/tools" | 2 | xmlns:tools="http://schemas.android.com/tools" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
6 | android:orientation="vertical" | 6 | android:orientation="vertical" |
7 | tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> | 7 | tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables"> |
8 | 8 | ||
9 | <RelativeLayout | 9 | <RelativeLayout |
10 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
11 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
12 | android:layout_marginTop="30dp"> | 12 | android:layout_marginTop="30dp"> |
13 | 13 | ||
14 | <ImageView | 14 | <ImageView |
15 | android:id="@+id/iv_student" | 15 | android:id="@+id/iv_student" |
16 | android:layout_width="35dp" | 16 | android:layout_width="35dp" |
17 | android:layout_height="35dp" | 17 | android:layout_height="35dp" |
18 | android:layout_centerVertical="true" | 18 | android:layout_centerVertical="true" |
19 | android:layout_marginStart="15dp" /> | 19 | android:layout_marginStart="15dp" /> |
20 | 20 | ||
21 | <TextView | 21 | <TextView |
22 | android:id="@+id/tv_name" | 22 | android:id="@+id/tv_name" |
23 | android:layout_width="wrap_content" | 23 | android:layout_width="wrap_content" |
24 | android:layout_height="wrap_content" | 24 | android:layout_height="wrap_content" |
25 | android:layout_centerVertical="true" | 25 | android:layout_centerVertical="true" |
26 | android:layout_marginStart="10dp" | 26 | android:layout_marginStart="10dp" |
27 | android:layout_toEndOf="@+id/iv_student" | 27 | android:layout_toEndOf="@+id/iv_student" |
28 | android:textColor="#333333" | 28 | android:textColor="#333333" |
29 | android:textSize="16sp" | 29 | android:textSize="16sp" |
30 | tools:ignore="RelativeOverlap" /> | 30 | tools:ignore="RelativeOverlap" /> |
31 | 31 | ||
32 | <androidx.appcompat.widget.AppCompatTextView | 32 | <androidx.appcompat.widget.AppCompatTextView |
33 | android:id="@+id/tv_choose" | 33 | android:id="@+id/tv_choose" |
34 | android:layout_width="wrap_content" | 34 | android:layout_width="wrap_content" |
35 | android:layout_height="wrap_content" | 35 | android:layout_height="wrap_content" |
36 | android:layout_alignParentEnd="true" | 36 | android:layout_alignParentEnd="true" |
37 | android:layout_centerVertical="true" | 37 | android:layout_centerVertical="true" |
38 | android:layout_marginEnd="15dp" | 38 | android:layout_marginEnd="15dp" |
39 | android:drawableEnd="@drawable/ic_filter_black" | 39 | android:drawableEnd="@drawable/ic_filter_black" |
40 | android:drawablePadding="5dp" | 40 | android:drawablePadding="5dp" |
41 | android:text="选择学生" | 41 | android:text="选择学生" |
42 | android:textColor="#333333" | 42 | android:textColor="#333333" |
43 | android:textSize="14sp" /> | 43 | android:textSize="14sp" /> |
44 | 44 | ||
45 | </RelativeLayout> | 45 | </RelativeLayout> |
46 | 46 | ||
47 | <LinearLayout | 47 | <LinearLayout |
48 | android:orientation="horizontal" | 48 | android:orientation="horizontal" |
49 | android:weightSum="2" | 49 | android:weightSum="2" |
50 | android:layout_width="match_parent" | 50 | android:layout_width="match_parent" |
51 | android:layout_height="wrap_content" | 51 | android:layout_height="wrap_content" |
52 | android:baselineAligned="false"> | 52 | android:baselineAligned="false"> |
53 | <FrameLayout | 53 | <FrameLayout |
54 | android:id="@+id/rl_take_photo" | 54 | android:id="@+id/rl_take_photo" |
55 | android:layout_width="0dp" | 55 | android:layout_width="0dp" |
56 | android:layout_weight="1" | 56 | android:layout_weight="1" |
57 | android:layout_height="wrap_content"> | 57 | android:layout_height="wrap_content"> |
58 | <ImageView | 58 | <ImageView |
59 | android:src="@drawable/png_entry_error" | 59 | android:src="@drawable/png_entry_error" |
60 | android:adjustViewBounds="true" | 60 | android:adjustViewBounds="true" |
61 | android:layout_width="match_parent" | 61 | android:layout_width="match_parent" |
62 | android:layout_height="wrap_content"/> | 62 | android:layout_height="wrap_content"/> |
63 | 63 | ||
64 | <TextView | 64 | <TextView |
65 | android:layout_width="wrap_content" | 65 | android:layout_width="wrap_content" |
66 | android:layout_height="wrap_content" | 66 | android:layout_height="wrap_content" |
67 | android:layout_gravity="center_horizontal|bottom" | 67 | android:layout_gravity="center_horizontal|bottom" |
68 | android:layout_marginBottom="38dp" | 68 | android:layout_marginBottom="38dp" |
69 | android:text="录入错题" | 69 | android:text="录入错题" |
70 | android:textColor="#EDF6FF" | 70 | android:textColor="#EDF6FF" |
71 | android:textSize="20sp" | 71 | android:textSize="20sp" |
72 | android:textStyle="bold" /> | 72 | android:textStyle="bold" /> |
73 | </FrameLayout> | 73 | </FrameLayout> |
74 | 74 | ||
75 | <FrameLayout | 75 | <FrameLayout |
76 | android:id="@+id/flEntryHomework" | 76 | android:id="@+id/flEntryHomework" |
77 | android:layout_width="0dp" | 77 | android:layout_width="0dp" |
78 | android:layout_weight="1" | 78 | android:layout_weight="1" |
79 | android:layout_height="wrap_content"> | 79 | android:layout_height="wrap_content"> |
80 | <ImageView | 80 | <ImageView |
81 | android:src="@drawable/png_entry_homework" | 81 | android:src="@drawable/png_entry_homework" |
82 | android:adjustViewBounds="true" | 82 | android:adjustViewBounds="true" |
83 | android:layout_width="match_parent" | 83 | android:layout_width="match_parent" |
84 | android:layout_height="wrap_content"/> | 84 | android:layout_height="wrap_content"/> |
85 | 85 | ||
86 | <TextView | 86 | <TextView |
87 | android:layout_width="wrap_content" | 87 | android:layout_width="wrap_content" |
88 | android:layout_height="wrap_content" | 88 | android:layout_height="wrap_content" |
89 | android:layout_gravity="center_horizontal|bottom" | 89 | android:layout_gravity="center_horizontal|bottom" |
90 | android:layout_marginBottom="38dp" | 90 | android:layout_marginBottom="38dp" |
91 | android:text="录入作业" | 91 | android:text="录入作业" |
92 | android:textColor="#EDF6FF" | 92 | android:textColor="#EDF6FF" |
93 | android:textSize="20sp" | 93 | android:textSize="20sp" |
94 | android:textStyle="bold" /> | 94 | android:textStyle="bold" /> |
95 | </FrameLayout> | 95 | </FrameLayout> |
96 | </LinearLayout> | 96 | </LinearLayout> |
97 | 97 | ||
98 | <LinearLayout | 98 | <LinearLayout |
99 | android:orientation="vertical" | 99 | android:orientation="vertical" |
100 | android:background="@drawable/shape_radius_10" | 100 | android:background="@drawable/shape_radius_10" |
101 | android:backgroundTint="@color/white" | 101 | android:backgroundTint="@color/white" |
102 | android:layout_marginHorizontal="15dp" | 102 | android:layout_marginHorizontal="15dp" |
103 | android:layout_marginTop="10dp" | 103 | android:layout_marginTop="10dp" |
104 | android:layout_marginBottom="15dp" | 104 | android:layout_marginBottom="15dp" |
105 | android:layout_width="match_parent" | 105 | android:layout_width="match_parent" |
106 | android:layout_height="match_parent"> | 106 | android:layout_height="match_parent"> |
107 | 107 | ||
108 | <com.google.android.material.tabs.TabLayout | 108 | <com.google.android.material.tabs.TabLayout |
109 | android:id="@+id/tabLayout" | 109 | android:id="@+id/tabLayout" |
110 | app:tabMode="fixed" | 110 | app:tabMode="fixed" |
111 | app:tabGravity="fill" | 111 | app:tabGravity="fill" |
112 | app:tabIndicatorFullWidth="false" | 112 | app:tabIndicatorFullWidth="false" |
113 | app:tabIndicatorColor="#1C90F3" | 113 | app:tabIndicatorColor="#1C90F3" |
114 | app:tabTextColor="#333" | 114 | app:tabTextColor="#333" |
115 | app:tabSelectedTextColor="#1C90F3" | 115 | app:tabSelectedTextColor="#1C90F3" |
116 | app:tabTextAppearance="@style/tab_home_item" | 116 | app:tabTextAppearance="@style/tab_home_item" |
117 | app:tabRippleColor="@color/transparent" | 117 | app:tabRippleColor="@color/transparent" |
118 | android:background="@drawable/bg_tab_home" | 118 | android:background="@drawable/bg_tab_home" |
119 | android:paddingBottom="4dp" | 119 | android:paddingBottom="4dp" |
120 | android:layout_width="match_parent" | 120 | android:layout_width="match_parent" |
121 | android:layout_height="36dp"/> | 121 | android:layout_height="36dp"/> |
122 | 122 | ||
123 | <androidx.recyclerview.widget.RecyclerView | 123 | <androidx.recyclerview.widget.RecyclerView |
124 | android:id="@+id/rvSubject" | 124 | android:id="@+id/rvSubject" |
125 | android:orientation="horizontal" | 125 | android:orientation="horizontal" |
126 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 126 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
127 | android:layout_marginTop="15dp" | 127 | android:layout_marginTop="15dp" |
128 | android:layout_width="match_parent" | 128 | android:layout_width="match_parent" |
129 | android:layout_height="wrap_content" /> | 129 | android:layout_height="wrap_content" /> |
130 | 130 | ||
131 | <LinearLayout | 131 | <LinearLayout |
132 | android:layout_marginTop="16dp" | 132 | android:layout_marginTop="16dp" |
133 | android:layout_marginHorizontal="10dp" | 133 | android:layout_marginHorizontal="10dp" |
134 | android:layout_width="match_parent" | 134 | android:layout_width="match_parent" |
135 | android:layout_height="25dp"> | 135 | android:layout_height="25dp"> |
136 | <TextView | 136 | <TextView |
137 | android:id="@+id/tvListTitle" | 137 | android:id="@+id/tvListTitle" |
138 | android:layout_width="wrap_content" | 138 | android:layout_width="wrap_content" |
139 | android:layout_height="wrap_content" | 139 | android:layout_height="wrap_content" |
140 | android:text="最近错题" | 140 | android:text="最近错题" |
141 | android:textColor="#333333" | 141 | android:textColor="#333333" |
142 | android:textSize="16sp" | 142 | android:textSize="16sp" |
143 | android:textStyle="bold" /> | 143 | android:textStyle="bold" /> |
144 | 144 | ||
145 | <Space style="@style/empty_space"/> | 145 | <Space style="@style/empty_space"/> |
146 | 146 | ||
147 | <LinearLayout | 147 | <LinearLayout |
148 | android:id="@+id/ll_all" | 148 | android:id="@+id/ll_all" |
149 | android:layout_width="wrap_content" | 149 | android:layout_width="wrap_content" |
150 | android:layout_height="wrap_content" | 150 | android:layout_height="wrap_content" |
151 | android:layout_gravity="center_vertical"> | 151 | android:layout_gravity="center_vertical"> |
152 | 152 | ||
153 | <TextView | 153 | <TextView |
154 | android:layout_width="wrap_content" | 154 | android:layout_width="wrap_content" |
155 | android:layout_height="wrap_content" | 155 | android:layout_height="wrap_content" |
156 | android:layout_gravity="center_vertical" | 156 | android:layout_gravity="center_vertical" |
157 | android:text="查看全部" | 157 | android:text="查看全部" |
158 | android:textColor="#666666" | 158 | android:textColor="#666666" |
159 | android:textSize="12sp" /> | 159 | android:textSize="12sp" /> |
160 | 160 | ||
161 | <ImageView | 161 | <ImageView |
162 | android:layout_width="9dp" | 162 | android:layout_width="9dp" |
163 | android:layout_height="10dp" | 163 | android:layout_height="10dp" |
164 | android:layout_gravity="center_vertical" | 164 | android:layout_gravity="center_vertical" |
165 | android:layout_marginStart="5dp" | 165 | android:layout_marginStart="5dp" |
166 | android:src="@mipmap/ic_arrow_right" /> | 166 | android:src="@mipmap/ic_arrow_right" /> |
167 | </LinearLayout> | 167 | </LinearLayout> |
168 | </LinearLayout> | 168 | </LinearLayout> |
169 | 169 | ||
170 | <androidx.recyclerview.widget.RecyclerView | 170 | <androidx.recyclerview.widget.RecyclerView |
171 | android:id="@+id/rvMain" | 171 | android:id="@+id/rvMain" |
172 | android:orientation="vertical" | 172 | android:orientation="vertical" |
173 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | 173 | app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
174 | android:layout_width="match_parent" | 174 | android:layout_width="match_parent" |
175 | android:layout_height="match_parent" | 175 | android:layout_height="match_parent" |
176 | android:layout_marginTop="15dp" /> | 176 | android:layout_marginTop="15dp" /> |
177 | 177 | ||
178 | <LinearLayout | 178 | <LinearLayout |
179 | android:id="@+id/ll_empty" | 179 | android:id="@+id/ll_empty" |
180 | android:layout_width="wrap_content" | 180 | android:layout_width="wrap_content" |
181 | android:layout_height="wrap_content" | 181 | android:layout_height="wrap_content" |
182 | android:layout_gravity="center_horizontal" | 182 | android:layout_gravity="center_horizontal" |
183 | android:layout_marginTop="30dp" | 183 | android:layout_marginTop="30dp" |
184 | android:orientation="vertical" | 184 | android:orientation="vertical" |
185 | android:visibility="gone"> | 185 | android:visibility="gone"> |
186 | 186 | ||
187 | <ImageView | 187 | <ImageView |
188 | android:layout_width="155dp" | 188 | android:layout_width="155dp" |
189 | android:layout_height="130dp" | 189 | android:layout_height="130dp" |
190 | android:src="@mipmap/ic_empty" /> | 190 | android:src="@mipmap/ic_empty" /> |
191 | 191 | ||
192 | <TextView | 192 | <TextView |
193 | android:id="@+id/tvEmpty" | ||
193 | android:layout_width="wrap_content" | 194 | android:layout_width="wrap_content" |
194 | android:layout_height="wrap_content" | 195 | android:layout_height="wrap_content" |
195 | android:layout_gravity="center_horizontal" | 196 | android:layout_gravity="center_horizontal" |
196 | android:text="暂无错题~" /> | 197 | android:text="暂无错题~" /> |
197 | </LinearLayout> | 198 | </LinearLayout> |
198 | 199 | ||
199 | </LinearLayout> | 200 | </LinearLayout> |
200 | </LinearLayout> | 201 | </LinearLayout> |