Browse Source

优化导出问题

zk 1 year ago
parent
commit
547d9bb65e

+ 11 - 0
app/src/main/java/com/datarecovery/master/module/imgrecover/ImageRecoverActivity.java

@@ -54,6 +54,7 @@ public class ImageRecoverActivity extends BaseActivity<ActivityImageRecoverBindi
     private final int[] tabTitle = {R.string.photo, R.string.wx, R.string.qq, R.string.other};
 
     private CommonSureDialog backDialog;
+    private CommonSureDialog clearDialog;
     private CommonLoadingDialog loadingDialog;
     private ScanProgressDialog scanProgressDialog;
     private ImageItemAdapter photoAdapter;
@@ -272,6 +273,16 @@ public class ImageRecoverActivity extends BaseActivity<ActivityImageRecoverBindi
             PreviewActivity.startImagePreView(this, allDetectedList, position);
         });
         imageRecoverViewModel.getShowLoadingEvent().observe(this, this::showLoadingDialog);
+        imageRecoverViewModel.getShowClearDialog().observe(this, o -> showClearDialog());
+    }
+
+    private void showClearDialog() {
+        if (clearDialog == null) {
+            clearDialog = new CommonSureDialog(this);
+            clearDialog.setDialogTitle(R.string.img_clear_sure_title).setDialogContent(R.string.img_clear_sure_content);
+            clearDialog.setOnDialogClickListener(() -> imageRecoverViewModel.executeImageDelete());
+        }
+        clearDialog.show();
     }
 
     private void showBackDialog() {

+ 9 - 2
app/src/main/java/com/datarecovery/master/module/imgrecover/ImageRecoverViewModel.java

@@ -46,6 +46,7 @@ public class ImageRecoverViewModel extends BaseViewModel {
 
     private final SingleLiveEvent<ImageDeepDetector.ImageFile> previewEvent = new SingleLiveEvent<>();
     private final SingleLiveEvent<?> detectedFinish = new SingleLiveEvent<>();
+    private final SingleLiveEvent<?> showClearDialog = new SingleLiveEvent<>();
     private final SingleLiveEvent<Boolean> showScanDialogEvent = new SingleLiveEvent<>();
     private final SingleLiveEvent<Boolean> showLoadingEvent = new SingleLiveEvent<>();
     private final SingleLiveEvent<?> notifyList = new SingleLiveEvent<>();
@@ -67,6 +68,10 @@ public class ImageRecoverViewModel extends BaseViewModel {
         initLiveData();
     }
 
+    public LiveData<?> getShowClearDialog() {
+        return showClearDialog;
+    }
+
     public LiveData<?> getNotifyList() {
         return notifyList;
     }
@@ -269,13 +274,13 @@ public class ImageRecoverViewModel extends BaseViewModel {
 
     public void onOperationClick() {
         if (type == ImageRecoverActivity.Type.DELETE) {
-            onDeleteClick();
+            showClearDialog.call();
         } else {
             onExportClick();
         }
     }
 
-    private void onDeleteClick() {
+    public void executeImageDelete() {
         List<ImageDeepDetector.ImageFile> list = getList(selectedList);
         if (list.size() == 0) {
             return;
@@ -303,6 +308,7 @@ public class ImageRecoverViewModel extends BaseViewModel {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.delete_success, ToastUtil.LENGTH_SHORT);
             list.clear();
+            selectedList.setValue(list);
             notifyList.call();
         }, throwable -> {
             showLoadingEvent.setValue(false);
@@ -328,6 +334,7 @@ public class ImageRecoverViewModel extends BaseViewModel {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_success, ToastUtil.LENGTH_SHORT);
             list.clear();
+            selectedList.setValue(list);
         }, throwable -> {
             showLoadingEvent.setValue(false);
             ToastUtil.show(R.string.export_fail, ToastUtil.LENGTH_SHORT);

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -176,4 +176,6 @@
     <string name="copy_success">复制成功</string>
     <string name="no_login">账号未登录</string>
     <string name="member_clear_buy">立即删除</string>
+    <string name="img_clear_sure_title">您确定清除吗?</string>
+    <string name="img_clear_sure_content">清除后,图片将彻底消失</string>
 </resources>