Commit 34c4b7cd1c298beca5d57442b20348f99b000d75
1 parent
324693cab8
Exists in
master
BUG修改
Showing
6 changed files
with
157 additions
and
58 deletions
Show diff stats
app/src/main/java/com/hjx/parent/AddSuccessActivity.java
... | ... | @@ -91,6 +91,12 @@ public class AddSuccessActivity extends BaseActivity<ActivityAddSuccessBinding> |
91 | 91 | dialog.show(); |
92 | 92 | } |
93 | 93 | }); |
94 | + binding.tvBook.setOnClickListener(new View.OnClickListener() { | |
95 | + @Override | |
96 | + public void onClick(View v) { | |
97 | + startActivity(new Intent(context, ErrorListActivity.class)); | |
98 | + } | |
99 | + }); | |
94 | 100 | } |
95 | 101 | |
96 | 102 | @Override | ... | ... |
app/src/main/java/com/hjx/parent/BaseActivity.java
... | ... | @@ -47,6 +47,18 @@ public abstract class BaseActivity<VB extends ViewBinding> extends AppCompatActi |
47 | 47 | .show(); |
48 | 48 | } |
49 | 49 | |
50 | + public void showLoadingDialog(String text, LoadingDialog.DismissListener listener) { | |
51 | + if (dialog != null) | |
52 | + dialog.close(); | |
53 | + dialog = new LoadingDialog(this); | |
54 | + dialog.setLoadingText(text) | |
55 | + .setSuccessText("成功")//显示加载成功时的文字 | |
56 | + .setFailedText("失败") | |
57 | + .setLoadSpeed(SPEED_TWO) | |
58 | + .show(); | |
59 | + dialog.setDimissListener(listener); | |
60 | + } | |
61 | + | |
50 | 62 | public void loadFail(String text) { |
51 | 63 | dialog.setFailedText(text); |
52 | 64 | dialog.loadFailed(); | ... | ... |
app/src/main/java/com/hjx/parent/ErrorListActivity.java
... | ... | @@ -19,6 +19,7 @@ import android.widget.CompoundButton; |
19 | 19 | import android.widget.RadioButton; |
20 | 20 | import android.widget.RadioGroup; |
21 | 21 | import android.widget.TextView; |
22 | +import android.widget.Toast; | |
22 | 23 | |
23 | 24 | import androidx.annotation.Nullable; |
24 | 25 | import androidx.core.content.FileProvider; |
... | ... | @@ -27,6 +28,9 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
27 | 28 | import androidx.recyclerview.widget.RecyclerView; |
28 | 29 | |
29 | 30 | import com.google.gson.Gson; |
31 | +import com.hjq.permissions.OnPermissionCallback; | |
32 | +import com.hjq.permissions.Permission; | |
33 | +import com.hjq.permissions.XXPermissions; | |
30 | 34 | import com.hjx.parent.adapter.ErrorAdapter; |
31 | 35 | import com.hjx.parent.adapter.FilterAdapter; |
32 | 36 | import com.hjx.parent.adapter.LoadMoreOnScrollListener; |
... | ... | @@ -198,51 +202,29 @@ public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> im |
198 | 202 | }); |
199 | 203 | break; |
200 | 204 | case R.id.tv_add: |
201 | - MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | |
202 | - View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | |
203 | - dialog.setContentView(bottomView); | |
204 | - bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | |
205 | - @Override | |
206 | - public void onClick(View view) { | |
207 | - dialog.dismiss(); | |
208 | - Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
209 | - //确保有相机来处理Intent | |
210 | - filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | |
211 | - File photoFile = new File(filePath); | |
212 | - if (photoFile != null) { | |
213 | - //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | |
214 | - Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | |
215 | - takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | |
216 | - takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | |
217 | - activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | |
218 | - } | |
219 | - } | |
220 | - }); | |
221 | - bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | |
222 | - @Override | |
223 | - public void onClick(View view) { | |
224 | - dialog.dismiss(); | |
225 | - ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | |
226 | - .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | |
227 | - .multiSelect(true) //是否多选 | |
228 | - .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | |
229 | - .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | |
230 | - .maxImageSelectable(9) //图片可选择数 | |
231 | - .maxHeight(1920) //图片最大高度 | |
232 | - .maxWidth(1920) //图片最大宽度 | |
233 | - .maxImageSize(10) //图片最大大小Mb | |
234 | - .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(); | |
235 | - ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | |
205 | + if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { | |
206 | + XXPermissions.with(context) | |
207 | + // 申请多个权限 | |
208 | + .permission(Permission.CAMERA) | |
209 | + .request(new OnPermissionCallback() { | |
210 | + @Override | |
211 | + public void onGranted(List<String> permissions, boolean all) { | |
212 | + if (all) { | |
213 | + //开启扫码界面 | |
214 | + showButtonDialog(); | |
215 | + } else { | |
216 | + Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); | |
217 | + } | |
218 | + } | |
236 | 219 | |
237 | - } | |
238 | - }); | |
239 | - bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | |
240 | - @Override | |
241 | - public void onClick(View view) { | |
242 | - dialog.dismiss(); | |
243 | - } | |
244 | - }); | |
245 | - dialog.show(); | |
220 | + @Override | |
221 | + public void onDenied(List<String> permissions, boolean never) { | |
222 | + XXPermissions.startPermissionActivity(context, permissions); | |
223 | + } | |
224 | + }); | |
225 | + } else { | |
226 | + showButtonDialog(); | |
227 | + } | |
246 | 228 | break; |
247 | 229 | case R.id.tv_save: |
248 | 230 | if (adapter.getChecKList().size() > 0) { |
... | ... | @@ -266,6 +248,54 @@ public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> im |
266 | 248 | } |
267 | 249 | } |
268 | 250 | |
251 | + private void showButtonDialog() { | |
252 | + MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | |
253 | + View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | |
254 | + dialog.setContentView(bottomView); | |
255 | + bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | |
256 | + @Override | |
257 | + public void onClick(View view) { | |
258 | + dialog.dismiss(); | |
259 | + Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
260 | + //确保有相机来处理Intent | |
261 | + filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | |
262 | + File photoFile = new File(filePath); | |
263 | + if (photoFile != null) { | |
264 | + //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | |
265 | + Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | |
266 | + takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | |
267 | + takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | |
268 | + activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | |
269 | + } | |
270 | + } | |
271 | + }); | |
272 | + bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | |
273 | + @Override | |
274 | + public void onClick(View view) { | |
275 | + dialog.dismiss(); | |
276 | + ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | |
277 | + .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | |
278 | + .multiSelect(true) //是否多选 | |
279 | + .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | |
280 | + .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | |
281 | + .maxImageSelectable(9) //图片可选择数 | |
282 | + .maxHeight(1920) //图片最大高度 | |
283 | + .maxWidth(1920) //图片最大宽度 | |
284 | + .maxImageSize(10) //图片最大大小Mb | |
285 | + .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(); | |
286 | + ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorListActivity.this); | |
287 | + | |
288 | + } | |
289 | + }); | |
290 | + bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | |
291 | + @Override | |
292 | + public void onClick(View view) { | |
293 | + dialog.dismiss(); | |
294 | + } | |
295 | + }); | |
296 | + dialog.show(); | |
297 | + } | |
298 | + | |
269 | 299 | private void deleteError(List<TopicBean> topicBeans) { |
270 | 300 | List<String> list = new ArrayList<>(); |
271 | 301 | for (int i = 0; i < topicBeans.size(); i++) { |
... | ... | @@ -310,15 +340,17 @@ public class ErrorListActivity extends BaseActivity<ActivityErrorListBinding> im |
310 | 340 | binding.llFilterMore.setVisibility(View.GONE); |
311 | 341 | } else { |
312 | 342 | binding.llFilterMore.setVisibility(View.VISIBLE); |
313 | - last.setTextColor(getColor(R.color.text_title)); | |
314 | - Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | |
315 | - // 这一步必须要做,否则不会显示. | |
316 | - drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | |
317 | - last.setCompoundDrawables(null, null, drawable, null); | |
343 | + if (last != null) { | |
344 | + last.setTextColor(getColor(R.color.text_title)); | |
345 | + Drawable drawable = getResources().getDrawable(R.drawable.ic_filter_gray); | |
346 | + // 这一步必须要做,否则不会显示. | |
347 | + drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | |
348 | + last.setCompoundDrawables(null, null, drawable, null); | |
349 | + } | |
318 | 350 | binding.tvFilterMore.setTextColor(Color.parseColor("#1C90F3")); |
319 | 351 | Drawable drawable1 = getResources().getDrawable(R.drawable.ic_filter_blue); |
320 | 352 | // 这一步必须要做,否则不会显示. |
321 | - drawable1.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | |
353 | + drawable1.setBounds(0, 0, drawable1.getMinimumWidth(), drawable1.getMinimumHeight()); | |
322 | 354 | binding.tvFilterMore.setCompoundDrawables(null, null, drawable1, null); |
323 | 355 | last = binding.tvFilterMore; |
324 | 356 | } | ... | ... |
app/src/main/java/com/hjx/parent/ImageActivity.java
... | ... | @@ -31,6 +31,7 @@ import com.prws.common.bean.TopicBean; |
31 | 31 | import com.prws.common.net.NetWorks; |
32 | 32 | import com.prws.common.utils.BitmapUtils; |
33 | 33 | import com.prws.common.utils.CommonUtil; |
34 | +import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | |
34 | 35 | |
35 | 36 | import java.io.File; |
36 | 37 | import java.util.ArrayList; |
... | ... | @@ -65,23 +66,21 @@ public class ImageActivity extends BaseActivity<ActivityImageBinding> implements |
65 | 66 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
66 | 67 | @Override |
67 | 68 | public void onPageSelected(int position) { |
69 | + if (list.get(position).getCuts() == null) { | |
70 | + binding.ivPrevious.setEnabled(false); | |
71 | + binding.ivNext.setEnabled(false); | |
72 | + clearText(); | |
73 | + } | |
68 | 74 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
69 | 75 | if (position == 0) { |
70 | 76 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
71 | - binding.ivPrevious.setEnabled(false); | |
72 | 77 | } else { |
73 | 78 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
74 | - binding.ivPrevious.setEnabled(true); | |
75 | 79 | } |
76 | 80 | if (position == list.size() - 1) { |
77 | 81 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
78 | - binding.ivNext.setEnabled(false); | |
79 | 82 | } else { |
80 | 83 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
81 | - binding.ivNext.setEnabled(true); | |
82 | - } | |
83 | - if (list.get(position).getCuts() == null) { | |
84 | - clearText(); | |
85 | 84 | } |
86 | 85 | super.onPageSelected(position); |
87 | 86 | } |
... | ... | @@ -97,7 +96,13 @@ public class ImageActivity extends BaseActivity<ActivityImageBinding> implements |
97 | 96 | |
98 | 97 | public void clearText() { |
99 | 98 | int index = binding.viewPager.getCurrentItem(); |
100 | - showLoadingDialog(getString(R.string.loading_text)); | |
99 | + showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | |
100 | + @Override | |
101 | + public void dimiss() { | |
102 | + binding.ivPrevious.setEnabled(index != 0); | |
103 | + binding.ivNext.setEnabled(index != list.size() - 1); | |
104 | + } | |
105 | + }); | |
101 | 106 | Log.i("clearText", list.get(index).getPath()); |
102 | 107 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
103 | 108 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | ... | ... |
app/src/main/java/com/hjx/parent/ImageSelectActivity.java
1 | 1 | package com.hjx.parent; |
2 | 2 | |
3 | +import android.app.Dialog; | |
3 | 4 | import android.content.Intent; |
4 | 5 | import android.graphics.Bitmap; |
5 | 6 | import android.graphics.BitmapFactory; |
... | ... | @@ -9,11 +10,13 @@ import android.graphics.Rect; |
9 | 10 | import android.os.Bundle; |
10 | 11 | import android.os.SystemClock; |
11 | 12 | import android.util.Log; |
13 | +import android.view.KeyEvent; | |
12 | 14 | import android.view.MotionEvent; |
13 | 15 | import android.view.View; |
14 | 16 | import android.widget.RelativeLayout; |
15 | 17 | |
16 | 18 | import com.hjx.parent.databinding.ActivityImageSelectBinding; |
19 | +import com.hjx.parent.dialog.TipDialog; | |
17 | 20 | import com.prws.common.bean.CutPicBean; |
18 | 21 | import com.prws.common.bean.ImageBean; |
19 | 22 | import com.prws.common.utils.BitmapUtils; |
... | ... | @@ -27,6 +30,7 @@ public class ImageSelectActivity extends BaseActivity<ActivityImageSelectBinding |
27 | 30 | private Bitmap backGroundBitmap; |
28 | 31 | private int bitmapWidth, bitmapHeight; |
29 | 32 | private Rect select; |
33 | + private boolean isSelect = false; | |
30 | 34 | |
31 | 35 | @Override |
32 | 36 | public void initView(Bundle savedInstanceState) { |
... | ... | @@ -36,6 +40,10 @@ public class ImageSelectActivity extends BaseActivity<ActivityImageSelectBinding |
36 | 40 | binding.markView.setmOnClickListener(new MarkSizeView.onClickListener() { |
37 | 41 | @Override |
38 | 42 | public void onConfirm(Rect markedArea) { |
43 | + if (isSelect) { | |
44 | + binding.markView.setBackGroundBitmap(backGroundBitmap); | |
45 | + isSelect = false; | |
46 | + } | |
39 | 47 | int markSizeViewWidth = binding.markView.getWidth(); |
40 | 48 | int markSizeHeight = binding.markView.getHeight(); |
41 | 49 | backGroundBitmap = binding.markView.getBackGroundBitmap(); |
... | ... | @@ -94,6 +102,27 @@ public class ImageSelectActivity extends BaseActivity<ActivityImageSelectBinding |
94 | 102 | } |
95 | 103 | } |
96 | 104 | }); |
105 | + binding.ivBack.setOnClickListener(new View.OnClickListener() { | |
106 | + @Override | |
107 | + public void onClick(View v) { | |
108 | + back(); | |
109 | + } | |
110 | + }); | |
111 | + } | |
112 | + | |
113 | + private void back() { | |
114 | + showTipDialog("温馨提示", "是否确认放弃当前的编辑?", "取消", "确定", new TipDialog.TipDialogInterface() { | |
115 | + @Override | |
116 | + public void onConfirm(Dialog dialog) { | |
117 | + dialog.dismiss(); | |
118 | + finish(); | |
119 | + } | |
120 | + | |
121 | + @Override | |
122 | + public void onCancel(Dialog dialog) { | |
123 | + dialog.dismiss(); | |
124 | + } | |
125 | + }); | |
97 | 126 | } |
98 | 127 | |
99 | 128 | private void simulateClick(int x1, int x2, int y1, int y2) { |
... | ... | @@ -111,6 +140,7 @@ public class ImageSelectActivity extends BaseActivity<ActivityImageSelectBinding |
111 | 140 | } |
112 | 141 | |
113 | 142 | private void drawRectangles(Rect ints) { |
143 | + isSelect = true; | |
114 | 144 | rect = new Rect(ints.left, ints.top, ints.right, ints.bottom); |
115 | 145 | Log.d(toString(), ints.toString()); |
116 | 146 | Rect rect = new Rect(CommonUtil.mulForInt(ints.left, widthFold), CommonUtil.mulForInt(ints.top, heightFold), CommonUtil.mulForInt(ints.right, widthFold), CommonUtil.mulForInt(ints.bottom, heightFold)); |
... | ... | @@ -183,6 +213,15 @@ public class ImageSelectActivity extends BaseActivity<ActivityImageSelectBinding |
183 | 213 | } |
184 | 214 | |
185 | 215 | @Override |
216 | + public boolean onKeyDown(int keyCode, KeyEvent event) { | |
217 | + if (keyCode == KeyEvent.KEYCODE_BACK) { | |
218 | + back(); | |
219 | + return true; | |
220 | + } | |
221 | + return super.onKeyDown(keyCode, event); | |
222 | + } | |
223 | + | |
224 | + @Override | |
186 | 225 | protected ActivityImageSelectBinding getViewBinding() { |
187 | 226 | return ActivityImageSelectBinding.inflate(getLayoutInflater()); |
188 | 227 | } | ... | ... |
app/src/main/java/com/hjx/parent/fragment/HomeFragment.java
... | ... | @@ -206,6 +206,11 @@ public class HomeFragment extends BaseFragment { |
206 | 206 | } |
207 | 207 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_schedule, schedules) { |
208 | 208 | @Override |
209 | + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | |
210 | + | |
211 | + } | |
212 | + | |
213 | + @Override | |
209 | 214 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
210 | 215 | Schedule schedule = schedules.get(item.getAdapterPosition()); |
211 | 216 | item.setText(R.id.tv_date, schedule.getDate()); | ... | ... |