Commit ff207bc53e5d92d4990f01482be6eec50accca4a
1 parent
937d37ac8b
Exists in
master
首页
Showing
2 changed files
with
14 additions
and
6 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.Observer; | 70 | import io.reactivex.Observer; |
70 | import io.reactivex.android.schedulers.AndroidSchedulers; | 71 | import io.reactivex.android.schedulers.AndroidSchedulers; |
71 | import io.reactivex.disposables.Disposable; | 72 | import io.reactivex.disposables.Disposable; |
72 | import io.reactivex.schedulers.Schedulers; | 73 | import io.reactivex.schedulers.Schedulers; |
73 | 74 | ||
74 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 75 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
75 | StudentBean studentBean; | 76 | StudentBean studentBean; |
76 | private int subject; | 77 | private int subject; |
77 | private ErrorAdapter errorAdapter; | 78 | private ErrorAdapter errorAdapter; |
78 | private HomeworkAdapter homeworkAdapter; | 79 | private HomeworkAdapter homeworkAdapter; |
79 | private String filePath; | 80 | private String filePath; |
80 | 81 | ||
81 | @Override | 82 | @Override |
82 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 83 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
83 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 84 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
84 | } | 85 | } |
85 | 86 | ||
86 | public void refreshStudent() { | 87 | public void refreshStudent() { |
87 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 88 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
88 | try { | 89 | try { |
89 | studentBean = new Gson().fromJson(student, StudentBean.class); | 90 | studentBean = new Gson().fromJson(student, StudentBean.class); |
90 | getBinding().tvChoose.setText(studentBean.getStuName()); | 91 | getBinding().tvChoose.setText(studentBean.getStuName()); |
91 | } catch (Exception e) { | 92 | } catch (Exception e) { |
92 | e.printStackTrace(); | 93 | e.printStackTrace(); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | @Override | 97 | @Override |
97 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 98 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
98 | super.onViewCreated(view, savedInstanceState); | 99 | super.onViewCreated(view, savedInstanceState); |
99 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 100 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
100 | if (!TextUtils.isEmpty(photo)) { | 101 | if (!TextUtils.isEmpty(photo)) { |
101 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 102 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
102 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 103 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
103 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 104 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
104 | } | 105 | } |
105 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 106 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
106 | getBinding().tvName.setText(name); | 107 | getBinding().tvName.setText(name); |
107 | refreshStudent(); | 108 | refreshStudent(); |
108 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 109 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
109 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 110 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
110 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 111 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
111 | 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))) { |
112 | @Override | 113 | @Override |
113 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 114 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
114 | 115 | ||
115 | } | 116 | } |
116 | 117 | ||
117 | @Override | 118 | @Override |
118 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 119 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
119 | 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()]); |
120 | switch (item.getAdapterPosition()) { | 121 | switch (item.getAdapterPosition()) { |
121 | case 0: | 122 | case 0: |
122 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 123 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
123 | break; | 124 | break; |
124 | case 1: | 125 | case 1: |
125 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 126 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
126 | break; | 127 | break; |
127 | case 2: | 128 | case 2: |
128 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
129 | break; | 130 | break; |
130 | case 3: | 131 | case 3: |
131 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
132 | break; | 133 | break; |
133 | case 4: | 134 | case 4: |
134 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 135 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
135 | break; | 136 | break; |
136 | } | 137 | } |
137 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 138 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
138 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 139 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
139 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 140 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
140 | item.getConvertView().setOnClickListener(v -> { | 141 | item.getConvertView().setOnClickListener(v -> { |
141 | if (subject != item.getAdapterPosition()) { | 142 | if (subject != item.getAdapterPosition()) { |
142 | subject = item.getAdapterPosition(); | 143 | subject = item.getAdapterPosition(); |
143 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 144 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
145 | getError(subStr); | ||
146 | getHomework(subStr); | ||
144 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 147 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
145 | getError(subStr); | 148 | binding.tvListTitle.setText("最近错题"); |
146 | } else { | 149 | } else { |
147 | // nothing can do | 150 | binding.tvListTitle.setText("最近作业"); |
148 | } | 151 | } |
149 | } | 152 | } |
150 | }); | 153 | }); |
151 | } | 154 | } |
152 | }; | 155 | }; |
153 | getBinding().rvSubject.setAdapter(adapter); | 156 | getBinding().rvSubject.setAdapter(adapter); |
154 | subject = 0; | 157 | subject = 0; |
155 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 158 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
156 | getBinding().llAll.setOnClickListener(v -> { | 159 | getBinding().llAll.setOnClickListener(v -> { |
157 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 160 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
158 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 161 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
159 | startActivity(intent); | 162 | startActivity(intent); |
160 | } else { | 163 | } else { |
161 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | 164 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); |
162 | startActivity(intent); | 165 | startActivity(intent); |
163 | } | 166 | } |
164 | }); | 167 | }); |
165 | 168 | ||
166 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 169 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
167 | homeworkAdapter = new HomeworkAdapter(); | 170 | homeworkAdapter = new HomeworkAdapter(); |
168 | binding.rvMain.setAdapter(errorAdapter); | 171 | binding.rvMain.setAdapter(errorAdapter); |
169 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 172 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
170 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 173 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
171 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 174 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
172 | @Override | 175 | @Override |
173 | public void onTabSelected(TabLayout.Tab tab) { | 176 | public void onTabSelected(TabLayout.Tab tab) { |
174 | if (tab.getPosition() == 0) { | 177 | if (tab.getPosition() == 0) { |
175 | binding.rvMain.setAdapter(errorAdapter); | 178 | binding.rvMain.setAdapter(errorAdapter); |
176 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 179 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
177 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 180 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
178 | } else { | 181 | } else { |
179 | binding.rvMain.setAdapter(homeworkAdapter); | 182 | binding.rvMain.setAdapter(homeworkAdapter); |
180 | binding.rvMain.setVisibility(View.VISIBLE); | 183 | binding.rvMain.setVisibility(View.VISIBLE); |
181 | binding.llEmpty.setVisibility(View.GONE); | 184 | binding.llEmpty.setVisibility(View.GONE); |
182 | } | 185 | } |
183 | } | 186 | } |
184 | @Override | 187 | @Override |
185 | public void onTabUnselected(TabLayout.Tab tab) { | 188 | public void onTabUnselected(TabLayout.Tab tab) { |
186 | } | 189 | } |
187 | @Override | 190 | @Override |
188 | public void onTabReselected(TabLayout.Tab tab) { | 191 | public void onTabReselected(TabLayout.Tab tab) { |
189 | } | 192 | } |
190 | }); | 193 | }); |
191 | } | 194 | } |
192 | 195 | ||
193 | private void takePhoto(int type) { | 196 | private void takePhoto(int type) { |
194 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 197 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
195 | XXPermissions.with(getContext()) | 198 | XXPermissions.with(getContext()) |
196 | // 申请多个权限 | 199 | // 申请多个权限 |
197 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 200 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
198 | @Override | 201 | @Override |
199 | public void onGranted(List<String> permissions, boolean all) { | 202 | public void onGranted(List<String> permissions, boolean all) { |
200 | if (all) { | 203 | if (all) { |
201 | //开启扫码界面 | 204 | //开启扫码界面 |
202 | showButtonDialog(type); | 205 | showButtonDialog(type); |
203 | } else { | 206 | } else { |
204 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 207 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
205 | } | 208 | } |
206 | } | 209 | } |
207 | 210 | ||
208 | @Override | 211 | @Override |
209 | public void onDenied(List<String> permissions, boolean never) { | 212 | public void onDenied(List<String> permissions, boolean never) { |
210 | XXPermissions.startPermissionActivity(getContext(), permissions); | 213 | XXPermissions.startPermissionActivity(getContext(), permissions); |
211 | } | 214 | } |
212 | }); | 215 | }); |
213 | } else { | 216 | } else { |
214 | showButtonDialog(type); | 217 | showButtonDialog(type); |
215 | } | 218 | } |
216 | } | 219 | } |
217 | 220 | ||
218 | private void showButtonDialog(int type) { | 221 | private void showButtonDialog(int type) { |
219 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 222 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
220 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 223 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
221 | dialog.setContentView(bottomView); | 224 | dialog.setContentView(bottomView); |
222 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 225 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
223 | @Override | 226 | @Override |
224 | public void onClick(View view) { | 227 | public void onClick(View view) { |
225 | dialog.dismiss(); | 228 | dialog.dismiss(); |
226 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 229 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
227 | //确保有相机来处理Intent | 230 | //确保有相机来处理Intent |
228 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 231 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
229 | File photoFile = new File(filePath); | 232 | File photoFile = new File(filePath); |
230 | 233 | ||
231 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 234 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
232 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 235 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
233 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 236 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
234 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 237 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
235 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 238 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
236 | } | 239 | } |
237 | }); | 240 | }); |
238 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 241 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
239 | @Override | 242 | @Override |
240 | public void onClick(View view) { | 243 | public void onClick(View view) { |
241 | dialog.dismiss(); | 244 | dialog.dismiss(); |
242 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 245 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
243 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 246 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
244 | .multiSelect(true) //是否多选 | 247 | .multiSelect(true) //是否多选 |
245 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 248 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
246 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 249 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
247 | .maxImageSelectable(5) //图片可选择数 | 250 | .maxImageSelectable(5) //图片可选择数 |
248 | .maxHeight(1920) //图片最大高度 | 251 | .maxHeight(1920) //图片最大高度 |
249 | .maxWidth(1920) //图片最大宽度 | 252 | .maxWidth(1920) //图片最大宽度 |
250 | .maxImageSize(3) //图片最大大小Mb | 253 | .maxImageSize(3) //图片最大大小Mb |
251 | .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(); | 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(); |
252 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 255 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
253 | 256 | ||
254 | } | 257 | } |
255 | }); | 258 | }); |
256 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 259 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
257 | @Override | 260 | @Override |
258 | public void onClick(View view) { | 261 | public void onClick(View view) { |
259 | dialog.dismiss(); | 262 | dialog.dismiss(); |
260 | } | 263 | } |
261 | }); | 264 | }); |
262 | dialog.show(); | 265 | dialog.show(); |
263 | } | 266 | } |
264 | 267 | ||
265 | @SuppressLint("CheckResult") | 268 | @SuppressLint("CheckResult") |
266 | protected void getHomework() { | 269 | protected void getHomework(String subject) { |
267 | if (studentBean == null) return; | 270 | if (studentBean == null) return; |
268 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 271 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
269 | .subscribeOn(Schedulers.io()) | 272 | .subscribeOn(Schedulers.io()) |
270 | .observeOn(AndroidSchedulers.mainThread()) | 273 | .observeOn(AndroidSchedulers.mainThread()) |
271 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 274 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
272 | .map(ResponseResult::getData) | 275 | .map(ResponseResult::getData) |
276 | .toObservable() | ||
277 | .flatMap(Observable::fromIterable) | ||
278 | .filter(data -> subject.equals(data.getSubject())) | ||
279 | .toList() | ||
273 | .subscribe((data, th) -> { | 280 | .subscribe((data, th) -> { |
274 | if (th != null) th.printStackTrace(); | 281 | if (th != null) th.printStackTrace(); |
275 | if (data != null) { | 282 | if (data != null) { |
276 | Collections.sort(data); | 283 | Collections.sort(data); |
277 | } | 284 | } |
278 | homeworkAdapter.setNewData(data); | 285 | homeworkAdapter.setNewData(data); |
279 | }); | 286 | }); |
280 | } | 287 | } |
281 | 288 | ||
282 | private void getError(String subject) { | 289 | private void getError(String subject) { |
283 | if (studentBean == null) { | 290 | if (studentBean == null) { |
284 | return; | 291 | return; |
285 | } | 292 | } |
286 | Map<String, Object> map = new HashMap<>(); | 293 | Map<String, Object> map = new HashMap<>(); |
287 | map.put("subject", subject); | 294 | map.put("subject", subject); |
288 | map.put("stuId", studentBean.getStuId()); | 295 | map.put("stuId", studentBean.getStuId()); |
289 | map.put("pageSize", 5); | 296 | map.put("pageSize", 5); |
290 | map.put("pageNum", 1); | 297 | map.put("pageNum", 1); |
291 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 298 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
292 | @Override | 299 | @Override |
293 | public void onSubscribe(Disposable d) { | 300 | public void onSubscribe(Disposable d) { |
294 | } | 301 | } |
295 | @Override | 302 | @Override |
296 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 303 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
297 | if (result.getData() != null && result.getCode() == 200) { | 304 | if (result.getData() != null && result.getCode() == 200) { |
298 | List<TopicBean> topicBeans = result.getData().getList(); | 305 | List<TopicBean> topicBeans = result.getData().getList(); |
299 | errorAdapter.refresh(topicBeans); | 306 | errorAdapter.refresh(topicBeans); |
300 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 307 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
301 | if (topicBeans.size() > 0) { | 308 | if (topicBeans.size() > 0) { |
302 | getBinding().rvMain.setVisibility(View.VISIBLE); | 309 | getBinding().rvMain.setVisibility(View.VISIBLE); |
303 | getBinding().llEmpty.setVisibility(View.GONE); | 310 | getBinding().llEmpty.setVisibility(View.GONE); |
304 | } else { | 311 | } else { |
305 | getBinding().rvMain.setVisibility(View.GONE); | 312 | getBinding().rvMain.setVisibility(View.GONE); |
306 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 313 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
307 | } | 314 | } |
308 | } | 315 | } |
309 | } | 316 | } |
310 | } | 317 | } |
311 | @Override | 318 | @Override |
312 | public void onError(Throwable e) { | 319 | public void onError(Throwable e) { |
313 | e.printStackTrace(); | 320 | e.printStackTrace(); |
314 | } | 321 | } |
315 | @Override | 322 | @Override |
316 | public void onComplete() { | 323 | public void onComplete() { |
317 | } | 324 | } |
318 | }); | 325 | }); |
319 | } | 326 | } |
320 | 327 | ||
321 | @Override | 328 | @Override |
322 | public void onResume() { | 329 | public void onResume() { |
323 | super.onResume(); | 330 | super.onResume(); |
324 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 331 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
325 | getHomework(); | 332 | getError(subStr); |
333 | getHomework(subStr); | ||
326 | } | 334 | } |
327 | 335 | ||
328 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 336 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
329 | int type; | 337 | int type; |
330 | public HandlerCallBack(int type) { | 338 | public HandlerCallBack(int type) { |
331 | this.type = type; | 339 | this.type = type; |
332 | } | 340 | } |
333 | 341 | ||
334 | private String TAG = "---ImagePicker---"; | 342 | private String TAG = "---ImagePicker---"; |
335 | List<ImageInfo> photoList = new ArrayList<>(); | 343 | List<ImageInfo> photoList = new ArrayList<>(); |
336 | 344 | ||
337 | @Override | 345 | @Override |
338 | public void onStart() { | 346 | public void onStart() { |
339 | Log.i(TAG, "onStart: 开启"); | 347 | Log.i(TAG, "onStart: 开启"); |
340 | } | 348 | } |
341 | 349 | ||
342 | @Override | 350 | @Override |
343 | public void onSuccess(List<ImageInfo> photoList) { | 351 | public void onSuccess(List<ImageInfo> photoList) { |
344 | this.photoList = photoList; | 352 | this.photoList = photoList; |
345 | Log.i(TAG, "onSuccess: 返回数据"); | 353 | Log.i(TAG, "onSuccess: 返回数据"); |
346 | } | 354 | } |
347 | 355 | ||
348 | @Override | 356 | @Override |
349 | public void onCancel() { | 357 | public void onCancel() { |
350 | Log.i(TAG, "onCancel: 取消"); | 358 | Log.i(TAG, "onCancel: 取消"); |
351 | } | 359 | } |
352 | 360 | ||
353 | @Override | 361 | @Override |
354 | public void onFinish(List<ImageInfo> selectImage) { | 362 | public void onFinish(List<ImageInfo> selectImage) { |
355 | if (selectImage.size() == photoList.size()) { | 363 | if (selectImage.size() == photoList.size()) { |
356 | ArrayList<String> strings = new ArrayList<>(); | 364 | ArrayList<String> strings = new ArrayList<>(); |
357 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 365 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
358 | for (ImageInfo imageInfo : selectImage) { | 366 | for (ImageInfo imageInfo : selectImage) { |
359 | strings.add(imageInfo.getPath()); | 367 | strings.add(imageInfo.getPath()); |
360 | } | 368 | } |
361 | intent.putStringArrayListExtra("images", strings); | 369 | intent.putStringArrayListExtra("images", strings); |
362 | intent.putExtra("type", type); | 370 | intent.putExtra("type", type); |
363 | startActivity(intent); | 371 | startActivity(intent); |
364 | } | 372 | } |
365 | } | 373 | } |
366 | 374 | ||
367 | @Override | 375 | @Override |
368 | public void onError() { | 376 | public void onError() { |
369 | Log.i(TAG, "onError: 出错"); | 377 | Log.i(TAG, "onError: 出错"); |
370 | } | 378 | } |
371 | } | 379 | } |
372 | 380 | ||
373 | @Override | 381 | @Override |
374 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 382 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
375 | super.onActivityResult(requestCode, resultCode, data); | 383 | super.onActivityResult(requestCode, resultCode, data); |
376 | if (resultCode != RESULT_OK) return; | 384 | if (resultCode != RESULT_OK) return; |
377 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 385 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
378 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 386 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
379 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 387 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
380 | CommonUtil.saveBitmapToUri(b, path); | 388 | CommonUtil.saveBitmapToUri(b, path); |
381 | ArrayList<String> strings = new ArrayList<>(); | 389 | ArrayList<String> strings = new ArrayList<>(); |
382 | Intent intent = new Intent(getContext(), ImageActivity.class); | 390 | Intent intent = new Intent(getContext(), ImageActivity.class); |
383 | strings.add(path); | 391 | strings.add(path); |
384 | intent.putStringArrayListExtra("images", strings); | 392 | intent.putStringArrayListExtra("images", strings); |
385 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 393 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
386 | startActivity(intent); | 394 | startActivity(intent); |
387 | } | 395 | } |
388 | } | 396 | } |
389 | } | 397 | } |
390 | 398 |
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:layout_width="wrap_content" | 193 | android:layout_width="wrap_content" |
194 | android:layout_height="wrap_content" | 194 | android:layout_height="wrap_content" |
195 | android:layout_gravity="center_horizontal" | 195 | android:layout_gravity="center_horizontal" |
196 | android:text="暂无错题~" /> | 196 | android:text="暂无错题~" /> |
197 | </LinearLayout> | 197 | </LinearLayout> |
198 | 198 | ||
199 | </LinearLayout> | 199 | </LinearLayout> |
200 | </LinearLayout> | 200 | </LinearLayout> |