Commit 6eabc0ad3da5c0bc917d45594c5091ed968c4259
1 parent
9cfa01d011
Exists in
master
规范资源
Showing
22 changed files
with
10 additions
and
14 deletions
Show diff stats
app/src/main/java/com/hjx/parent/ErrorBookActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.content.Intent; | 3 | import android.content.Intent; |
4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
5 | import android.graphics.BitmapFactory; | 5 | import android.graphics.BitmapFactory; |
6 | import android.net.Uri; | 6 | import android.net.Uri; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | import android.provider.MediaStore; | 8 | import android.provider.MediaStore; |
9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
10 | import android.util.Log; | 10 | import android.util.Log; |
11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
12 | import android.view.View; | 12 | import android.view.View; |
13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
14 | import android.widget.LinearLayout; | 14 | import android.widget.LinearLayout; |
15 | import android.widget.Toast; | 15 | import android.widget.Toast; |
16 | 16 | ||
17 | import androidx.annotation.NonNull; | 17 | import androidx.annotation.NonNull; |
18 | import androidx.annotation.Nullable; | 18 | import androidx.annotation.Nullable; |
19 | import androidx.core.content.FileProvider; | 19 | import androidx.core.content.FileProvider; |
20 | import androidx.recyclerview.widget.LinearLayoutManager; | 20 | import androidx.recyclerview.widget.LinearLayoutManager; |
21 | import androidx.recyclerview.widget.RecyclerView; | 21 | import androidx.recyclerview.widget.RecyclerView; |
22 | 22 | ||
23 | import com.chad.library.adapter.base.BaseQuickAdapter; | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
24 | import com.chad.library.adapter.base.BaseViewHolder; | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | import com.hjq.permissions.OnPermissionCallback; | 26 | import com.hjq.permissions.OnPermissionCallback; |
27 | import com.hjq.permissions.Permission; | 27 | import com.hjq.permissions.Permission; |
28 | import com.hjq.permissions.XXPermissions; | 28 | import com.hjq.permissions.XXPermissions; |
29 | import com.hjx.parent.adapter.ErrorAdapter; | 29 | import com.hjx.parent.adapter.ErrorAdapter; |
30 | import com.hjx.parent.bean.StudentBean; | 30 | import com.hjx.parent.bean.StudentBean; |
31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | 31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
32 | import com.prws.common.base.BasePresenter; | ||
33 | import com.prws.common.bean.ImageBean; | ||
34 | import com.prws.common.bean.PageInfo; | 32 | import com.prws.common.bean.PageInfo; |
35 | import com.prws.common.bean.ResponseResult; | 33 | import com.prws.common.bean.ResponseResult; |
36 | import com.prws.common.bean.TopicBean; | 34 | import com.prws.common.bean.TopicBean; |
37 | import com.prws.common.net.NetWorks; | 35 | import com.prws.common.net.NetWorks; |
38 | import com.prws.common.utils.BitmapUtils; | 36 | import com.prws.common.utils.BitmapUtils; |
39 | import com.prws.common.utils.CommonUtil; | 37 | import com.prws.common.utils.CommonUtil; |
40 | import com.prws.common.utils.SharedPreferencesUtil; | 38 | import com.prws.common.utils.SharedPreferencesUtil; |
41 | import com.prws.common.utils.dialog.MyButtomDialog; | 39 | import com.prws.common.utils.dialog.MyButtomDialog; |
42 | import com.zhangteng.imagepicker.bean.ImageInfo; | 40 | import com.zhangteng.imagepicker.bean.ImageInfo; |
43 | import com.zhangteng.imagepicker.callback.HandlerCallBack; | ||
44 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 41 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
45 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 42 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
46 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 43 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
47 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 44 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
48 | import com.zhangteng.utils.IHandlerCallBack; | 45 | import com.zhangteng.utils.IHandlerCallBack; |
49 | 46 | ||
50 | import java.io.File; | 47 | import java.io.File; |
51 | import java.util.ArrayList; | 48 | import java.util.ArrayList; |
52 | import java.util.Arrays; | 49 | import java.util.Arrays; |
53 | import java.util.HashMap; | 50 | import java.util.HashMap; |
54 | import java.util.List; | 51 | import java.util.List; |
55 | import java.util.Map; | 52 | import java.util.Map; |
56 | 53 | ||
57 | import io.reactivex.Observer; | 54 | import io.reactivex.Observer; |
58 | import io.reactivex.disposables.Disposable; | 55 | import io.reactivex.disposables.Disposable; |
59 | 56 | ||
60 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { | 57 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { |
61 | StudentBean studentBean; | 58 | StudentBean studentBean; |
62 | private int subject; | 59 | private int subject; |
63 | private ErrorAdapter adapter; | 60 | private ErrorAdapter adapter; |
64 | private int REQUEST_CODE_IMAGE = 123; | 61 | private int REQUEST_CODE_IMAGE = 123; |
65 | private String filePath; | 62 | private String filePath; |
66 | 63 | ||
67 | @Override | 64 | @Override |
68 | public void initView(Bundle savedInstanceState) { | 65 | public void initView(Bundle savedInstanceState) { |
69 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 66 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
70 | try { | 67 | try { |
71 | studentBean = new Gson().fromJson(student, StudentBean.class); | 68 | studentBean = new Gson().fromJson(student, StudentBean.class); |
72 | } catch (Exception e) { | 69 | } catch (Exception e) { |
73 | 70 | ||
74 | } | 71 | } |
75 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 72 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
76 | @Override | 73 | @Override |
77 | public void onClick(View v) { | 74 | public void onClick(View v) { |
78 | finish(); | 75 | finish(); |
79 | } | 76 | } |
80 | }); | 77 | }); |
81 | binding.rlTakePhoto.post(new Runnable() { | 78 | binding.rlTakePhoto.post(new Runnable() { |
82 | @Override | 79 | @Override |
83 | public void run() { | 80 | public void run() { |
84 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); | 81 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); |
85 | layoutParams.width = CommonUtil.getScreenWidth(context); | 82 | layoutParams.width = CommonUtil.getScreenWidth(context); |
86 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; | 83 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; |
87 | binding.rlTakePhoto.setLayoutParams(layoutParams); | 84 | binding.rlTakePhoto.setLayoutParams(layoutParams); |
88 | } | 85 | } |
89 | }); | 86 | }); |
90 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { | 87 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
91 | @Override | 88 | @Override |
92 | public void onClick(View v) { | 89 | public void onClick(View v) { |
93 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 90 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
94 | XXPermissions.with(context) | 91 | XXPermissions.with(context) |
95 | // 申请多个权限 | 92 | // 申请多个权限 |
96 | .permission(Permission.CAMERA) | 93 | .permission(Permission.CAMERA) |
97 | .request(new OnPermissionCallback() { | 94 | .request(new OnPermissionCallback() { |
98 | @Override | 95 | @Override |
99 | public void onGranted(List<String> permissions, boolean all) { | 96 | public void onGranted(List<String> permissions, boolean all) { |
100 | if (all) { | 97 | if (all) { |
101 | //开启扫码界面 | 98 | //开启扫码界面 |
102 | showButtonDialog(); | 99 | showButtonDialog(); |
103 | } else { | 100 | } else { |
104 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | 101 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
105 | } | 102 | } |
106 | } | 103 | } |
107 | 104 | ||
108 | @Override | 105 | @Override |
109 | public void onDenied(List<String> permissions, boolean never) { | 106 | public void onDenied(List<String> permissions, boolean never) { |
110 | XXPermissions.startPermissionActivity(context, permissions); | 107 | XXPermissions.startPermissionActivity(context, permissions); |
111 | } | 108 | } |
112 | }); | 109 | }); |
113 | } else { | 110 | } else { |
114 | showButtonDialog(); | 111 | showButtonDialog(); |
115 | } | 112 | } |
116 | 113 | ||
117 | } | 114 | } |
118 | }); | 115 | }); |
119 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 116 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
120 | @Override | 117 | @Override |
121 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 118 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
122 | 119 | ||
123 | } | 120 | } |
124 | 121 | ||
125 | @Override | 122 | @Override |
126 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 123 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
127 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 124 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
128 | switch (item.getAdapterPosition()) { | 125 | switch (item.getAdapterPosition()) { |
129 | case 0: | 126 | case 0: |
130 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 127 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_chinese); |
131 | break; | 128 | break; |
132 | case 1: | 129 | case 1: |
133 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 130 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_math); |
134 | break; | 131 | break; |
135 | case 2: | 132 | case 2: |
136 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 133 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_english); |
137 | break; | 134 | break; |
138 | case 3: | 135 | case 3: |
139 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 136 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_physics); |
140 | break; | 137 | break; |
141 | case 4: | 138 | case 4: |
142 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 139 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_chemistry); |
143 | break; | 140 | break; |
144 | } | 141 | } |
145 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 142 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
146 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; | 143 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; |
147 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 144 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
148 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 145 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
149 | @Override | 146 | @Override |
150 | public void onClick(View v) { | 147 | public void onClick(View v) { |
151 | if (subject != item.getAdapterPosition()) { | 148 | if (subject != item.getAdapterPosition()) { |
152 | subject = item.getAdapterPosition(); | 149 | subject = item.getAdapterPosition(); |
153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 150 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
154 | } | 151 | } |
155 | } | 152 | } |
156 | }); | 153 | }); |
157 | } | 154 | } |
158 | }; | 155 | }; |
159 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); | 156 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); |
160 | binding.recycleSubject.setAdapter(adapter); | 157 | binding.recycleSubject.setAdapter(adapter); |
161 | subject = 0; | 158 | subject = 0; |
162 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 159 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
163 | binding.llAll.setOnClickListener(new View.OnClickListener() { | 160 | binding.llAll.setOnClickListener(new View.OnClickListener() { |
164 | @Override | 161 | @Override |
165 | public void onClick(View v) { | 162 | public void onClick(View v) { |
166 | Intent intent = new Intent(context, ErrorListActivity.class); | 163 | Intent intent = new Intent(context, ErrorListActivity.class); |
167 | startActivity(intent); | 164 | startActivity(intent); |
168 | } | 165 | } |
169 | }); | 166 | }); |
170 | } | 167 | } |
171 | 168 | ||
172 | @Override | 169 | @Override |
173 | protected ActivityErrorBookBinding getViewBinding() { | 170 | protected ActivityErrorBookBinding getViewBinding() { |
174 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); | 171 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); |
175 | } | 172 | } |
176 | 173 | ||
177 | private void showButtonDialog() { | 174 | private void showButtonDialog() { |
178 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 175 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); |
179 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 176 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); |
180 | dialog.setContentView(bottomView); | 177 | dialog.setContentView(bottomView); |
181 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 178 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
182 | @Override | 179 | @Override |
183 | public void onClick(View view) { | 180 | public void onClick(View view) { |
184 | dialog.dismiss(); | 181 | dialog.dismiss(); |
185 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 182 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
186 | //确保有相机来处理Intent | 183 | //确保有相机来处理Intent |
187 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 184 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
188 | File photoFile = new File(filePath); | 185 | File photoFile = new File(filePath); |
189 | if (photoFile != null) { | 186 | if (photoFile != null) { |
190 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 187 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
191 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 188 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
192 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 189 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
193 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 190 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
194 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 191 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); |
195 | } | 192 | } |
196 | } | 193 | } |
197 | }); | 194 | }); |
198 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 195 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
199 | @Override | 196 | @Override |
200 | public void onClick(View view) { | 197 | public void onClick(View view) { |
201 | dialog.dismiss(); | 198 | dialog.dismiss(); |
202 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 199 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
203 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | 200 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) |
204 | .multiSelect(true) //是否多选 | 201 | .multiSelect(true) //是否多选 |
205 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 202 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
206 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 203 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
207 | .maxImageSelectable(5) //图片可选择数 | 204 | .maxImageSelectable(5) //图片可选择数 |
208 | .maxHeight(1920) //图片最大高度 | 205 | .maxHeight(1920) //图片最大高度 |
209 | .maxWidth(1920) //图片最大宽度 | 206 | .maxWidth(1920) //图片最大宽度 |
210 | .maxImageSize(3) //图片最大大小Mb | 207 | .maxImageSize(3) //图片最大大小Mb |
211 | .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(); | 208 | .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(); |
212 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | 209 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); |
213 | 210 | ||
214 | } | 211 | } |
215 | }); | 212 | }); |
216 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 213 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
217 | @Override | 214 | @Override |
218 | public void onClick(View view) { | 215 | public void onClick(View view) { |
219 | dialog.dismiss(); | 216 | dialog.dismiss(); |
220 | } | 217 | } |
221 | }); | 218 | }); |
222 | dialog.show(); | 219 | dialog.show(); |
223 | } | 220 | } |
224 | 221 | ||
225 | private void getError(String subject) { | 222 | private void getError(String subject) { |
226 | if (studentBean != null) { | 223 | if (studentBean != null) { |
227 | Map map = new HashMap(); | 224 | Map map = new HashMap(); |
228 | map.put("subject", subject); | 225 | map.put("subject", subject); |
229 | map.put("stuId", studentBean.getStuId()); | 226 | map.put("stuId", studentBean.getStuId()); |
230 | map.put("pageSize", 5); | 227 | map.put("pageSize", 5); |
231 | map.put("pageNum", 1); | 228 | map.put("pageNum", 1); |
232 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 229 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
233 | @Override | 230 | @Override |
234 | public void onSubscribe(Disposable d) { | 231 | public void onSubscribe(Disposable d) { |
235 | 232 | ||
236 | } | 233 | } |
237 | 234 | ||
238 | @Override | 235 | @Override |
239 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 236 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
240 | if (result.getData() != null && result.getCode() == 200) { | 237 | if (result.getData() != null && result.getCode() == 200) { |
241 | List<TopicBean> topicBeans = result.getData().getList(); | 238 | List<TopicBean> topicBeans = result.getData().getList(); |
242 | loadError(topicBeans); | 239 | loadError(topicBeans); |
243 | } | 240 | } |
244 | } | 241 | } |
245 | 242 | ||
246 | @Override | 243 | @Override |
247 | public void onError(Throwable e) { | 244 | public void onError(Throwable e) { |
248 | e.toString(); | 245 | e.toString(); |
249 | } | 246 | } |
250 | 247 | ||
251 | @Override | 248 | @Override |
252 | public void onComplete() { | 249 | public void onComplete() { |
253 | 250 | ||
254 | } | 251 | } |
255 | }); | 252 | }); |
256 | } | 253 | } |
257 | } | 254 | } |
258 | 255 | ||
259 | @Override | 256 | @Override |
260 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 257 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
261 | super.onActivityResult(requestCode, resultCode, data); | 258 | super.onActivityResult(requestCode, resultCode, data); |
262 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 259 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
263 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 260 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
264 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 261 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
265 | CommonUtil.saveBitmapToUri(b, path); | 262 | CommonUtil.saveBitmapToUri(b, path); |
266 | List<String> strings = new ArrayList<>(); | 263 | List<String> strings = new ArrayList<>(); |
267 | Intent intent = new Intent(context, ImageActivity.class); | 264 | Intent intent = new Intent(context, ImageActivity.class); |
268 | strings.add(path); | 265 | strings.add(path); |
269 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 266 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
270 | startActivity(intent); | 267 | startActivity(intent); |
271 | } | 268 | } |
272 | } | 269 | } |
273 | 270 | ||
274 | private void loadError(List<TopicBean> list) { | 271 | private void loadError(List<TopicBean> list) { |
275 | if (list.size() > 0) { | 272 | if (list.size() > 0) { |
276 | binding.recycleError.setVisibility(View.VISIBLE); | 273 | binding.recycleError.setVisibility(View.VISIBLE); |
277 | binding.llEmpty.setVisibility(View.GONE); | 274 | binding.llEmpty.setVisibility(View.GONE); |
278 | if (adapter != null) { | 275 | if (adapter != null) { |
279 | adapter.refresh(list); | 276 | adapter.refresh(list); |
280 | } else { | 277 | } else { |
281 | adapter = new ErrorAdapter(context, list, false); | 278 | adapter = new ErrorAdapter(context, list, false); |
282 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); | 279 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); |
283 | binding.recycleError.setAdapter(adapter); | 280 | binding.recycleError.setAdapter(adapter); |
284 | } | 281 | } |
285 | } else { | 282 | } else { |
286 | binding.recycleError.setVisibility(View.GONE); | 283 | binding.recycleError.setVisibility(View.GONE); |
287 | binding.llEmpty.setVisibility(View.VISIBLE); | 284 | binding.llEmpty.setVisibility(View.VISIBLE); |
288 | } | 285 | } |
289 | } | 286 | } |
290 | 287 | ||
291 | @Override | 288 | @Override |
292 | protected void onResume() { | 289 | protected void onResume() { |
293 | super.onResume(); | 290 | super.onResume(); |
294 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 291 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
295 | } | 292 | } |
296 | 293 | ||
297 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 294 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
298 | private String TAG = "---ImagePicker---"; | 295 | private String TAG = "---ImagePicker---"; |
299 | List<ImageInfo> photoList = new ArrayList<>(); | 296 | List<ImageInfo> photoList = new ArrayList<>(); |
300 | 297 | ||
301 | @Override | 298 | @Override |
302 | public void onStart() { | 299 | public void onStart() { |
303 | Log.i(TAG, "onStart: 开启"); | 300 | Log.i(TAG, "onStart: 开启"); |
304 | } | 301 | } |
305 | 302 | ||
306 | @Override | 303 | @Override |
307 | public void onSuccess(List<ImageInfo> photoList) { | 304 | public void onSuccess(List<ImageInfo> photoList) { |
308 | this.photoList = photoList; | 305 | this.photoList = photoList; |
309 | Log.i(TAG, "onSuccess: 返回数据"); | 306 | Log.i(TAG, "onSuccess: 返回数据"); |
310 | } | 307 | } |
311 | 308 | ||
312 | @Override | 309 | @Override |
313 | public void onCancel() { | 310 | public void onCancel() { |
314 | Log.i(TAG, "onCancel: 取消"); | 311 | Log.i(TAG, "onCancel: 取消"); |
315 | } | 312 | } |
316 | 313 | ||
317 | @Override | 314 | @Override |
318 | public void onFinish(List<ImageInfo> selectImage) { | 315 | public void onFinish(List<ImageInfo> selectImage) { |
319 | if (selectImage.size() == photoList.size()) { | 316 | if (selectImage.size() == photoList.size()) { |
320 | List<String> strings = new ArrayList<>(); | 317 | List<String> strings = new ArrayList<>(); |
321 | Intent intent = new Intent(context, ImageActivity.class); | 318 | Intent intent = new Intent(context, ImageActivity.class); |
322 | for (ImageInfo imageInfo : selectImage) { | 319 | for (ImageInfo imageInfo : selectImage) { |
323 | strings.add(imageInfo.getPath()); | 320 | strings.add(imageInfo.getPath()); |
324 | } | 321 | } |
325 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 322 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
326 | startActivity(intent); | 323 | startActivity(intent); |
327 | } | 324 | } |
328 | } | 325 | } |
329 | 326 | ||
330 | @Override | 327 | @Override |
331 | public void onError() { | 328 | public void onError() { |
332 | Log.i(TAG, "onError: 出错"); | 329 | Log.i(TAG, "onError: 出错"); |
333 | } | 330 | } |
334 | } | 331 | } |
335 | } | 332 | } |
336 | 333 |
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.HomeworkDetailActivity; | 35 | import com.hjx.parent.HomeworkDetailActivity; |
36 | import com.hjx.parent.HomeworkShareActivity; | 36 | import com.hjx.parent.HomeworkShareActivity; |
37 | import com.hjx.parent.ImageActivity; | 37 | import com.hjx.parent.ImageActivity; |
38 | import com.hjx.parent.R; | 38 | import com.hjx.parent.R; |
39 | import com.hjx.parent.StuHomeworkActivity; | 39 | import com.hjx.parent.StuHomeworkActivity; |
40 | import com.hjx.parent.TeacherChooseActivity; | 40 | import com.hjx.parent.TeacherChooseActivity; |
41 | import com.hjx.parent.adapter.ErrorAdapter; | 41 | import com.hjx.parent.adapter.ErrorAdapter; |
42 | import com.hjx.parent.adapter.HomeworkAdapter; | 42 | import com.hjx.parent.adapter.HomeworkAdapter; |
43 | import com.hjx.parent.bean.StudentBean; | 43 | import com.hjx.parent.bean.StudentBean; |
44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; | 44 | import com.hjx.parent.databinding.FragmentErrorBookBinding; |
45 | import com.hjx.parent.rx.BaseRxFragment; | 45 | import com.hjx.parent.rx.BaseRxFragment; |
46 | import com.prws.common.bean.PageInfo; | 46 | import com.prws.common.bean.PageInfo; |
47 | import com.prws.common.bean.ResponseResult; | 47 | import com.prws.common.bean.ResponseResult; |
48 | import com.prws.common.bean.Student; | 48 | import com.prws.common.bean.Student; |
49 | import com.prws.common.bean.TopicBean; | 49 | import com.prws.common.bean.TopicBean; |
50 | import com.prws.common.bean.homework.HomeworkList; | 50 | import com.prws.common.bean.homework.HomeworkList; |
51 | import com.prws.common.net.NetWorks; | 51 | import com.prws.common.net.NetWorks; |
52 | import com.prws.common.utils.BitmapUtils; | 52 | import com.prws.common.utils.BitmapUtils; |
53 | import com.prws.common.utils.CommonUtil; | 53 | import com.prws.common.utils.CommonUtil; |
54 | import com.prws.common.utils.ScreenUtils; | 54 | import com.prws.common.utils.ScreenUtils; |
55 | import com.prws.common.utils.SharedPreferencesUtil; | 55 | import com.prws.common.utils.SharedPreferencesUtil; |
56 | import com.prws.common.utils.dialog.MyButtomDialog; | 56 | import com.prws.common.utils.dialog.MyButtomDialog; |
57 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; | 57 | import com.trello.rxlifecycle2.android.RxLifecycleAndroid; |
58 | import com.zhangteng.imagepicker.bean.ImageInfo; | 58 | import com.zhangteng.imagepicker.bean.ImageInfo; |
59 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 59 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
60 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 60 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
61 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 61 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
62 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 62 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
63 | import com.zhangteng.utils.IHandlerCallBack; | 63 | import com.zhangteng.utils.IHandlerCallBack; |
64 | 64 | ||
65 | import java.io.File; | 65 | import java.io.File; |
66 | import java.text.SimpleDateFormat; | 66 | import java.text.SimpleDateFormat; |
67 | import java.util.ArrayList; | 67 | import java.util.ArrayList; |
68 | import java.util.Arrays; | 68 | import java.util.Arrays; |
69 | import java.util.Collections; | ||
70 | import java.util.HashMap; | 69 | import java.util.HashMap; |
71 | import java.util.List; | 70 | import java.util.List; |
72 | import java.util.Locale; | 71 | import java.util.Locale; |
73 | import java.util.Map; | 72 | import java.util.Map; |
74 | 73 | ||
75 | import io.reactivex.Observable; | 74 | import io.reactivex.Observable; |
76 | import io.reactivex.Observer; | 75 | import io.reactivex.Observer; |
77 | import io.reactivex.android.schedulers.AndroidSchedulers; | 76 | import io.reactivex.android.schedulers.AndroidSchedulers; |
78 | import io.reactivex.disposables.Disposable; | 77 | import io.reactivex.disposables.Disposable; |
79 | import io.reactivex.schedulers.Schedulers; | 78 | import io.reactivex.schedulers.Schedulers; |
80 | 79 | ||
81 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { | 80 | public class ErrorFragment extends BaseRxFragment<FragmentErrorBookBinding> { |
82 | StudentBean studentBean; | 81 | StudentBean studentBean; |
83 | private int subject; | 82 | private int subject; |
84 | private ErrorAdapter errorAdapter; | 83 | private ErrorAdapter errorAdapter; |
85 | private HomeworkAdapter homeworkAdapter; | 84 | private HomeworkAdapter homeworkAdapter; |
86 | private String filePath; | 85 | private String filePath; |
87 | 86 | ||
88 | @Override | 87 | @Override |
89 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { | 88 | protected FragmentErrorBookBinding onCreateViewBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) { |
90 | return FragmentErrorBookBinding.inflate(inflater, parent, false); | 89 | return FragmentErrorBookBinding.inflate(inflater, parent, false); |
91 | } | 90 | } |
92 | 91 | ||
93 | public void refreshStudent() { | 92 | public void refreshStudent() { |
94 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 93 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
95 | try { | 94 | try { |
96 | studentBean = new Gson().fromJson(student, StudentBean.class); | 95 | studentBean = new Gson().fromJson(student, StudentBean.class); |
97 | getBinding().tvChoose.setText(studentBean.getStuName()); | 96 | getBinding().tvChoose.setText(studentBean.getStuName()); |
98 | } catch (Exception e) { | 97 | } catch (Exception e) { |
99 | e.printStackTrace(); | 98 | e.printStackTrace(); |
100 | } | 99 | } |
101 | } | 100 | } |
102 | 101 | ||
103 | @Override | 102 | @Override |
104 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 103 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
105 | super.onViewCreated(view, savedInstanceState); | 104 | super.onViewCreated(view, savedInstanceState); |
106 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); | 105 | String photo = (String) SharedPreferencesUtil.getData("photo", ""); |
107 | if (!TextUtils.isEmpty(photo)) { | 106 | if (!TextUtils.isEmpty(photo)) { |
108 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); | 107 | RoundedCorners roundedCorners = new RoundedCorners(ScreenUtils.dpToPx(getContext(), 45)); |
109 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); | 108 | RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); |
110 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); | 109 | Glide.with(getContext()).load(photo).apply(options).into(getBinding().ivStudent); |
111 | } | 110 | } |
112 | String name = (String) SharedPreferencesUtil.getData("name", ""); | 111 | String name = (String) SharedPreferencesUtil.getData("name", ""); |
113 | getBinding().tvName.setText(name); | 112 | getBinding().tvName.setText(name); |
114 | refreshStudent(); | 113 | refreshStudent(); |
115 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); | 114 | getBinding().tvChoose.setOnClickListener(v -> startActivity(new Intent(getContext(), TeacherChooseActivity.class))); |
116 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); | 115 | getBinding().rlTakePhoto.setOnClickListener(v -> takePhoto(0)); |
117 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); | 116 | getBinding().flEntryHomework.setOnClickListener(v -> takePhoto(1)); |
118 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 117 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
119 | @Override | 118 | @Override |
120 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 119 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
121 | 120 | ||
122 | } | 121 | } |
123 | 122 | ||
124 | @Override | 123 | @Override |
125 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 124 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
126 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 125 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
127 | switch (item.getAdapterPosition()) { | 126 | switch (item.getAdapterPosition()) { |
128 | case 0: | 127 | case 0: |
129 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 128 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_chinese); |
130 | break; | 129 | break; |
131 | case 1: | 130 | case 1: |
132 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 131 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_math); |
133 | break; | 132 | break; |
134 | case 2: | 133 | case 2: |
135 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 134 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_english); |
136 | break; | 135 | break; |
137 | case 3: | 136 | case 3: |
138 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 137 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_physics); |
139 | break; | 138 | break; |
140 | case 4: | 139 | case 4: |
141 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 140 | item.setImageResource(R.id.iv_subject, R.drawable.png_ic_chemistry); |
142 | break; | 141 | break; |
143 | } | 142 | } |
144 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 143 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
145 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; | 144 | layoutParams.width = (CommonUtil.getScreenWidth(getContext()) - CommonUtil.dpToPx(getContext(), 30)) / 4; |
146 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 145 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
147 | item.getConvertView().setOnClickListener(v -> { | 146 | item.getConvertView().setOnClickListener(v -> { |
148 | if (subject != item.getAdapterPosition()) { | 147 | if (subject != item.getAdapterPosition()) { |
149 | subject = item.getAdapterPosition(); | 148 | subject = item.getAdapterPosition(); |
150 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 149 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
151 | getError(subStr); | 150 | getError(subStr); |
152 | getHomework(subStr); | 151 | getHomework(subStr); |
153 | } | 152 | } |
154 | }); | 153 | }); |
155 | } | 154 | } |
156 | }; | 155 | }; |
157 | getBinding().rvSubject.setAdapter(adapter); | 156 | getBinding().rvSubject.setAdapter(adapter); |
158 | subject = 0; | 157 | subject = 0; |
159 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 158 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
160 | getBinding().llAll.setOnClickListener(v -> { | 159 | getBinding().llAll.setOnClickListener(v -> { |
161 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 160 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
162 | Intent intent = new Intent(getContext(), ErrorListActivity.class); | 161 | Intent intent = new Intent(getContext(), ErrorListActivity.class); |
163 | startActivity(intent); | 162 | startActivity(intent); |
164 | } else { | 163 | } else { |
165 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); | 164 | Intent intent = new Intent(getContext(), StuHomeworkActivity.class); |
166 | startActivity(intent); | 165 | startActivity(intent); |
167 | } | 166 | } |
168 | }); | 167 | }); |
169 | 168 | ||
170 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); | 169 | errorAdapter = new ErrorAdapter(getActivity(), new ArrayList<>(), false); |
171 | homeworkAdapter = new HomeworkAdapter(); | 170 | homeworkAdapter = new HomeworkAdapter(); |
172 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { | 171 | homeworkAdapter.setOnItemClickListener((baseQuickAdapter, view1, i) -> { |
173 | HomeworkList data = homeworkAdapter.getData().get(i); | 172 | HomeworkList data = homeworkAdapter.getData().get(i); |
174 | Gson gson = new Gson(); | 173 | Gson gson = new Gson(); |
175 | String json = gson.toJson(studentBean); | 174 | String json = gson.toJson(studentBean); |
176 | Student s = gson.fromJson(json, Student.class); | 175 | Student s = gson.fromJson(json, Student.class); |
177 | if (data.getRight() == null) { | 176 | if (data.getRight() == null) { |
178 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); | 177 | Intent intent = new Intent(requireContext(), HomeworkDetailActivity.class); |
179 | intent.putExtra("student", s); | 178 | intent.putExtra("student", s); |
180 | intent.putExtra("data", data); | 179 | intent.putExtra("data", data); |
181 | startActivity(intent); | 180 | startActivity(intent); |
182 | } else { | 181 | } else { |
183 | Intent intent = new Intent(requireContext(), HomeworkShareActivity.class); | 182 | Intent intent = new Intent(requireContext(), HomeworkShareActivity.class); |
184 | intent.putExtra("student", s); | 183 | intent.putExtra("student", s); |
185 | intent.putExtra("id", data.getId()); | 184 | intent.putExtra("id", data.getId()); |
186 | intent.putExtra("grade", data.getGrade()); | 185 | intent.putExtra("grade", data.getGrade()); |
187 | intent.putExtra("subject", data.getSubject()); | 186 | intent.putExtra("subject", data.getSubject()); |
188 | String name1 = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(data.uploadTime); | 187 | String name1 = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(data.uploadTime); |
189 | intent.putExtra("name", name1); | 188 | intent.putExtra("name", name1); |
190 | startActivity(intent); | 189 | startActivity(intent); |
191 | } | 190 | } |
192 | }); | 191 | }); |
193 | binding.rvMain.setAdapter(errorAdapter); | 192 | binding.rvMain.setAdapter(errorAdapter); |
194 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); | 193 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近错题")); |
195 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); | 194 | binding.tabLayout.addTab(binding.tabLayout.newTab().setText("最近作业")); |
196 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | 195 | binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
197 | @Override | 196 | @Override |
198 | public void onTabSelected(TabLayout.Tab tab) { | 197 | public void onTabSelected(TabLayout.Tab tab) { |
199 | if (tab.getPosition() == 0) { | 198 | if (tab.getPosition() == 0) { |
200 | binding.rvMain.setAdapter(errorAdapter); | 199 | binding.rvMain.setAdapter(errorAdapter); |
201 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); | 200 | binding.rvMain.setVisibility(errorAdapter.list.isEmpty() ? View.GONE : View.VISIBLE); |
202 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); | 201 | binding.llEmpty.setVisibility(errorAdapter.list.isEmpty() ? View.VISIBLE : View.GONE); |
203 | binding.tvListTitle.setText("最近错题"); | 202 | binding.tvListTitle.setText("最近错题"); |
204 | binding.tvEmpty.setText("暂无错题~"); | 203 | binding.tvEmpty.setText("暂无错题~"); |
205 | } else { | 204 | } else { |
206 | binding.rvMain.setAdapter(homeworkAdapter); | 205 | binding.rvMain.setAdapter(homeworkAdapter); |
207 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); | 206 | binding.rvMain.setVisibility(homeworkAdapter.getData().isEmpty() ? View.GONE : View.VISIBLE); |
208 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); | 207 | binding.llEmpty.setVisibility(homeworkAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE); |
209 | binding.tvListTitle.setText("最近作业"); | 208 | binding.tvListTitle.setText("最近作业"); |
210 | binding.tvEmpty.setText("暂无作业~"); | 209 | binding.tvEmpty.setText("暂无作业~"); |
211 | } | 210 | } |
212 | } | 211 | } |
213 | @Override | 212 | @Override |
214 | public void onTabUnselected(TabLayout.Tab tab) { | 213 | public void onTabUnselected(TabLayout.Tab tab) { |
215 | } | 214 | } |
216 | @Override | 215 | @Override |
217 | public void onTabReselected(TabLayout.Tab tab) { | 216 | public void onTabReselected(TabLayout.Tab tab) { |
218 | } | 217 | } |
219 | }); | 218 | }); |
220 | } | 219 | } |
221 | 220 | ||
222 | private void takePhoto(int type) { | 221 | private void takePhoto(int type) { |
223 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | 222 | if (!XXPermissions.isGranted(getContext(), Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
224 | XXPermissions.with(getContext()) | 223 | XXPermissions.with(getContext()) |
225 | // 申请多个权限 | 224 | // 申请多个权限 |
226 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { | 225 | .permission(Permission.CAMERA).request(new OnPermissionCallback() { |
227 | @Override | 226 | @Override |
228 | public void onGranted(List<String> permissions, boolean all) { | 227 | public void onGranted(List<String> permissions, boolean all) { |
229 | if (all) { | 228 | if (all) { |
230 | //开启扫码界面 | 229 | //开启扫码界面 |
231 | showButtonDialog(type); | 230 | showButtonDialog(type); |
232 | } else { | 231 | } else { |
233 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); | 232 | Toast.makeText(getContext(), "需要权限", Toast.LENGTH_SHORT).show(); |
234 | } | 233 | } |
235 | } | 234 | } |
236 | 235 | ||
237 | @Override | 236 | @Override |
238 | public void onDenied(List<String> permissions, boolean never) { | 237 | public void onDenied(List<String> permissions, boolean never) { |
239 | XXPermissions.startPermissionActivity(getContext(), permissions); | 238 | XXPermissions.startPermissionActivity(getContext(), permissions); |
240 | } | 239 | } |
241 | }); | 240 | }); |
242 | } else { | 241 | } else { |
243 | showButtonDialog(type); | 242 | showButtonDialog(type); |
244 | } | 243 | } |
245 | } | 244 | } |
246 | 245 | ||
247 | private void showButtonDialog(int type) { | 246 | private void showButtonDialog(int type) { |
248 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); | 247 | MyButtomDialog dialog = new MyButtomDialog(getActivity(), R.style.BottomSheetDialog); |
249 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); | 248 | View bottomView = LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_layout, null); |
250 | dialog.setContentView(bottomView); | 249 | dialog.setContentView(bottomView); |
251 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 250 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { |
252 | @Override | 251 | @Override |
253 | public void onClick(View view) { | 252 | public void onClick(View view) { |
254 | dialog.dismiss(); | 253 | dialog.dismiss(); |
255 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 254 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
256 | //确保有相机来处理Intent | 255 | //确保有相机来处理Intent |
257 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 256 | filePath = requireActivity().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
258 | File photoFile = new File(filePath); | 257 | File photoFile = new File(filePath); |
259 | 258 | ||
260 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 259 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
261 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); | 260 | Uri photoUri = FileProvider.getUriForFile(requireActivity(), "com.hjx.parent.fileprovider", photoFile); |
262 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 261 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
263 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 262 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
264 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); | 263 | startActivityForResult(takePictureIntent, type == 0 ? 0xA01 : 0xA02); |
265 | } | 264 | } |
266 | }); | 265 | }); |
267 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 266 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { |
268 | @Override | 267 | @Override |
269 | public void onClick(View view) { | 268 | public void onClick(View view) { |
270 | dialog.dismiss(); | 269 | dialog.dismiss(); |
271 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | 270 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getActivity().getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 |
272 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) | 271 | .iHandlerCallBack(new HandlerCallBack(type)) //图片选择器生命周期监听(直接打开摄像头时无效) |
273 | .multiSelect(true) //是否多选 | 272 | .multiSelect(true) //是否多选 |
274 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | 273 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false |
275 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | 274 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 |
276 | .maxImageSelectable(5) //图片可选择数 | 275 | .maxImageSelectable(5) //图片可选择数 |
277 | .maxHeight(1920) //图片最大高度 | 276 | .maxHeight(1920) //图片最大高度 |
278 | .maxWidth(1920) //图片最大宽度 | 277 | .maxWidth(1920) //图片最大宽度 |
279 | .maxImageSize(3) //图片最大大小Mb | 278 | .maxImageSize(3) //图片最大大小Mb |
280 | .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(); | 279 | .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(); |
281 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); | 280 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(getActivity()); |
282 | 281 | ||
283 | } | 282 | } |
284 | }); | 283 | }); |
285 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | 284 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { |
286 | @Override | 285 | @Override |
287 | public void onClick(View view) { | 286 | public void onClick(View view) { |
288 | dialog.dismiss(); | 287 | dialog.dismiss(); |
289 | } | 288 | } |
290 | }); | 289 | }); |
291 | dialog.show(); | 290 | dialog.show(); |
292 | } | 291 | } |
293 | 292 | ||
294 | @SuppressLint("CheckResult") | 293 | @SuppressLint("CheckResult") |
295 | protected void getHomework(String subject) { | 294 | protected void getHomework(String subject) { |
296 | if (studentBean == null) return; | 295 | if (studentBean == null) return; |
297 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) | 296 | NetWorks.service_url.getStudentHomework(NetWorks.getHeader(), studentBean.getStuId()) |
298 | .subscribeOn(Schedulers.io()) | 297 | .subscribeOn(Schedulers.io()) |
299 | .observeOn(AndroidSchedulers.mainThread()) | 298 | .observeOn(AndroidSchedulers.mainThread()) |
300 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) | 299 | .compose(RxLifecycleAndroid.bindFragment(getRxLifecycle())) |
301 | .map(ResponseResult::getData) | 300 | .map(ResponseResult::getData) |
302 | .toObservable() | 301 | .toObservable() |
303 | .concatMap(Observable::fromIterable) | 302 | .concatMap(Observable::fromIterable) |
304 | .filter(data -> subject.equals(data.getSubject())) | 303 | .filter(data -> subject.equals(data.getSubject())) |
305 | //.filter(data -> data.getRight() == null) | 304 | //.filter(data -> data.getRight() == null) |
306 | .take(5) | 305 | .take(5) |
307 | .toList() | 306 | .toList() |
308 | .subscribe((data, th) -> { | 307 | .subscribe((data, th) -> { |
309 | if (th != null) th.printStackTrace(); | 308 | if (th != null) th.printStackTrace(); |
310 | homeworkAdapter.setNewData(data); | 309 | homeworkAdapter.setNewData(data); |
311 | if (binding.tabLayout.getSelectedTabPosition() == 1) { | 310 | if (binding.tabLayout.getSelectedTabPosition() == 1) { |
312 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); | 311 | binding.rvMain.setVisibility(data == null || data.isEmpty() ? View.GONE : View.VISIBLE); |
313 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); | 312 | binding.llEmpty.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE); |
314 | } | 313 | } |
315 | }); | 314 | }); |
316 | } | 315 | } |
317 | 316 | ||
318 | private void getError(String subject) { | 317 | private void getError(String subject) { |
319 | if (studentBean == null) { | 318 | if (studentBean == null) { |
320 | return; | 319 | return; |
321 | } | 320 | } |
322 | Map<String, Object> map = new HashMap<>(); | 321 | Map<String, Object> map = new HashMap<>(); |
323 | map.put("subject", subject); | 322 | map.put("subject", subject); |
324 | map.put("stuId", studentBean.getStuId()); | 323 | map.put("stuId", studentBean.getStuId()); |
325 | map.put("pageSize", 5); | 324 | map.put("pageSize", 5); |
326 | map.put("pageNum", 1); | 325 | map.put("pageNum", 1); |
327 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 326 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
328 | @Override | 327 | @Override |
329 | public void onSubscribe(Disposable d) { | 328 | public void onSubscribe(Disposable d) { |
330 | } | 329 | } |
331 | @Override | 330 | @Override |
332 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 331 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
333 | if (result.getData() != null && result.getCode() == 200) { | 332 | if (result.getData() != null && result.getCode() == 200) { |
334 | List<TopicBean> topicBeans = result.getData().getList(); | 333 | List<TopicBean> topicBeans = result.getData().getList(); |
335 | errorAdapter.refresh(topicBeans); | 334 | errorAdapter.refresh(topicBeans); |
336 | if (binding.tabLayout.getSelectedTabPosition() == 0) { | 335 | if (binding.tabLayout.getSelectedTabPosition() == 0) { |
337 | if (topicBeans.size() > 0) { | 336 | if (topicBeans.size() > 0) { |
338 | getBinding().rvMain.setVisibility(View.VISIBLE); | 337 | getBinding().rvMain.setVisibility(View.VISIBLE); |
339 | getBinding().llEmpty.setVisibility(View.GONE); | 338 | getBinding().llEmpty.setVisibility(View.GONE); |
340 | } else { | 339 | } else { |
341 | getBinding().rvMain.setVisibility(View.GONE); | 340 | getBinding().rvMain.setVisibility(View.GONE); |
342 | getBinding().llEmpty.setVisibility(View.VISIBLE); | 341 | getBinding().llEmpty.setVisibility(View.VISIBLE); |
343 | } | 342 | } |
344 | } | 343 | } |
345 | } | 344 | } |
346 | } | 345 | } |
347 | @Override | 346 | @Override |
348 | public void onError(Throwable e) { | 347 | public void onError(Throwable e) { |
349 | e.printStackTrace(); | 348 | e.printStackTrace(); |
350 | } | 349 | } |
351 | @Override | 350 | @Override |
352 | public void onComplete() { | 351 | public void onComplete() { |
353 | } | 352 | } |
354 | }); | 353 | }); |
355 | } | 354 | } |
356 | 355 | ||
357 | @Override | 356 | @Override |
358 | public void onResume() { | 357 | public void onResume() { |
359 | super.onResume(); | 358 | super.onResume(); |
360 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; | 359 | String subStr = getResources().getStringArray(R.array.filter_subject)[subject]; |
361 | getError(subStr); | 360 | getError(subStr); |
362 | getHomework(subStr); | 361 | getHomework(subStr); |
363 | } | 362 | } |
364 | 363 | ||
365 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 364 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
366 | int type; | 365 | int type; |
367 | public HandlerCallBack(int type) { | 366 | public HandlerCallBack(int type) { |
368 | this.type = type; | 367 | this.type = type; |
369 | } | 368 | } |
370 | 369 | ||
371 | private String TAG = "---ImagePicker---"; | 370 | private String TAG = "---ImagePicker---"; |
372 | List<ImageInfo> photoList = new ArrayList<>(); | 371 | List<ImageInfo> photoList = new ArrayList<>(); |
373 | 372 | ||
374 | @Override | 373 | @Override |
375 | public void onStart() { | 374 | public void onStart() { |
376 | Log.i(TAG, "onStart: 开启"); | 375 | Log.i(TAG, "onStart: 开启"); |
377 | } | 376 | } |
378 | 377 | ||
379 | @Override | 378 | @Override |
380 | public void onSuccess(List<ImageInfo> photoList) { | 379 | public void onSuccess(List<ImageInfo> photoList) { |
381 | this.photoList = photoList; | 380 | this.photoList = photoList; |
382 | Log.i(TAG, "onSuccess: 返回数据"); | 381 | Log.i(TAG, "onSuccess: 返回数据"); |
383 | } | 382 | } |
384 | 383 | ||
385 | @Override | 384 | @Override |
386 | public void onCancel() { | 385 | public void onCancel() { |
387 | Log.i(TAG, "onCancel: 取消"); | 386 | Log.i(TAG, "onCancel: 取消"); |
388 | } | 387 | } |
389 | 388 | ||
390 | @Override | 389 | @Override |
391 | public void onFinish(List<ImageInfo> selectImage) { | 390 | public void onFinish(List<ImageInfo> selectImage) { |
392 | if (selectImage.size() == photoList.size()) { | 391 | if (selectImage.size() == photoList.size()) { |
393 | ArrayList<String> strings = new ArrayList<>(); | 392 | ArrayList<String> strings = new ArrayList<>(); |
394 | Intent intent = new Intent(getActivity(), ImageActivity.class); | 393 | Intent intent = new Intent(getActivity(), ImageActivity.class); |
395 | for (ImageInfo imageInfo : selectImage) { | 394 | for (ImageInfo imageInfo : selectImage) { |
396 | strings.add(imageInfo.getPath()); | 395 | strings.add(imageInfo.getPath()); |
397 | } | 396 | } |
398 | intent.putStringArrayListExtra("images", strings); | 397 | intent.putStringArrayListExtra("images", strings); |
399 | intent.putExtra("type", type); | 398 | intent.putExtra("type", type); |
400 | startActivity(intent); | 399 | startActivity(intent); |
401 | } | 400 | } |
402 | } | 401 | } |
403 | 402 | ||
404 | @Override | 403 | @Override |
405 | public void onError() { | 404 | public void onError() { |
406 | Log.i(TAG, "onError: 出错"); | 405 | Log.i(TAG, "onError: 出错"); |
407 | } | 406 | } |
408 | } | 407 | } |
409 | 408 | ||
410 | @Override | 409 | @Override |
411 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 410 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
412 | super.onActivityResult(requestCode, resultCode, data); | 411 | super.onActivityResult(requestCode, resultCode, data); |
413 | if (resultCode != RESULT_OK) return; | 412 | if (resultCode != RESULT_OK) return; |
414 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { | 413 | if (requestCode == 0xA01 || requestCode == 0xA02 && !TextUtils.isEmpty(filePath)) { |
415 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 414 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
416 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 415 | String path = getContext().getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
417 | CommonUtil.saveBitmapToUri(b, path); | 416 | CommonUtil.saveBitmapToUri(b, path); |
418 | ArrayList<String> strings = new ArrayList<>(); | 417 | ArrayList<String> strings = new ArrayList<>(); |
419 | Intent intent = new Intent(getContext(), ImageActivity.class); | 418 | Intent intent = new Intent(getContext(), ImageActivity.class); |
420 | strings.add(path); | 419 | strings.add(path); |
421 | intent.putStringArrayListExtra("images", strings); | 420 | intent.putStringArrayListExtra("images", strings); |
422 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); | 421 | intent.putExtra("type", requestCode == 0xA01 ? 0 : 1); |
423 | startActivity(intent); | 422 | startActivity(intent); |
424 | } | 423 | } |
425 | } | 424 | } |
426 | } | 425 | } |
427 | 426 |
app/src/main/res/drawable/png_ic_chemistry.png
17.2 KB
app/src/main/res/drawable/png_ic_chinese.png
23.2 KB
app/src/main/res/drawable/png_ic_english.png
19 KB
app/src/main/res/drawable/png_ic_math.png
17.7 KB
app/src/main/res/drawable/png_ic_physics.png
17.1 KB
app/src/main/res/mipmap-xhdpi/ic_chemistry.png
6.96 KB
app/src/main/res/mipmap-xhdpi/ic_chinese.png
23.2 KB
app/src/main/res/mipmap-xhdpi/ic_english.png
8 KB
app/src/main/res/mipmap-xhdpi/ic_math.png
7.35 KB
app/src/main/res/mipmap-xhdpi/ic_physics.png
7.06 KB
app/src/main/res/mipmap-xxhdpi/ic_chemistry.png
17.2 KB
app/src/main/res/mipmap-xxhdpi/ic_chinese.png
23.2 KB
app/src/main/res/mipmap-xxhdpi/ic_english.png
19 KB
app/src/main/res/mipmap-xxhdpi/ic_math.png
17.7 KB
app/src/main/res/mipmap-xxhdpi/ic_physics.png
17.1 KB
app/src/main/res/mipmap-xxxhdpi/ic_chemistry.png
26.6 KB
app/src/main/res/mipmap-xxxhdpi/ic_chinese.png
23.2 KB
app/src/main/res/mipmap-xxxhdpi/ic_english.png
29.4 KB
app/src/main/res/mipmap-xxxhdpi/ic_math.png
26.5 KB
app/src/main/res/mipmap-xxxhdpi/ic_physics.png
26.3 KB