Browse Source

解决删除仍显示的问题

zk 1 year ago
parent
commit
658b4afbf5

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

@@ -36,6 +36,7 @@ import com.datarecovery.master.utils.BoxingUtil;
 import com.datarecovery.master.utils.FilePermissionHelper;
 import com.datarecovery.master.utils.GridRecoverItemDecoration;
 import com.datarecovery.master.utils.ImageDeepDetector;
+import com.datarecovery.master.utils.ToastUtil;
 import com.google.android.material.tabs.TabLayout;
 import com.gyf.immersionbar.ImmersionBar;
 
@@ -208,6 +209,7 @@ public class ImageRecoverActivity extends BaseActivity<ActivityImageRecoverBindi
         if (imageFile == null) {
             return;
         }
+//        ToastUtil.show(imageFile.getPath(), ToastUtil.LENGTH_SHORT);
         if (Objects.equals(imageRecoverViewModel.getType(), MemberType.APP_IMAGE_CLEAN)) {
             imageRecoverViewModel.setItemCheck(imageFile);
         } else {

+ 18 - 11
app/src/main/java/com/datarecovery/master/module/imgrecover/ImageRecoverViewModel.java

@@ -371,12 +371,9 @@ public class ImageRecoverViewModel extends BaseViewModel {
                             List<ImageDeepDetector.ImageFile> itemList = getList(liveData);
                             itemList.remove(item);
                         }
-                        detectedPhotoImg.postValue(getList(detectedPhotoImg));
-                        detectedWxImg.postValue(getList(detectedWxImg));
-                        detectedQQImg.postValue(getList(detectedQQImg));
-                        detectedOtherImg.postValue(getList(detectedOtherImg));
                         list.removeAll(pair.first);
                         selectedList.postValue(list);
+                        notifyList.postValue(null);
                     }
                     return pair.second;
                 })
@@ -407,17 +404,27 @@ public class ImageRecoverViewModel extends BaseViewModel {
                     @Override
                     public void onSuccess(@NonNull Boolean result) {
                         showLoadingEvent.setValue(false);
-                        detectedPhotoImg.setValue(getList(detectedPhotoImg));
-                        detectedWxImg.setValue(getList(detectedWxImg));
-                        detectedQQImg.setValue(getList(detectedQQImg));
-                        detectedOtherImg.setValue(getList(detectedOtherImg));
-                        ToastUtil.show(R.string.delete_success, ToastUtil.LENGTH_SHORT);
-                        checkAll.setValue(false);
                         if (result) {
+                            for (ImageDeepDetector.ImageFile item : list) {
+                                MutableLiveData<List<ImageDeepDetector.ImageFile>> liveData;
+                                if (item.getCategory() == ImageDeepDetector.ImageFile.CATEGORY_GALLERY) {
+                                    liveData = detectedPhotoImg;
+                                } else if (item.getCategory() == ImageDeepDetector.ImageFile.CATEGORY_WECHAT) {
+                                    liveData = detectedWxImg;
+                                } else if (item.getCategory() == ImageDeepDetector.ImageFile.CATEGORY_QQ) {
+                                    liveData = detectedQQImg;
+                                } else {
+                                    liveData = detectedOtherImg;
+                                }
+                                List<ImageDeepDetector.ImageFile> itemList = getList(liveData);
+                                itemList.remove(item);
+                            }
+                            ToastUtil.show(R.string.delete_success, ToastUtil.LENGTH_SHORT);
                             list.clear();
                             selectedList.setValue(list);
+                            notifyList.call();
                         }
-                        notifyList.call();
+                        checkAll.setValue(false);
                     }
 
                     @Override

+ 9 - 1
app/src/main/java/com/datarecovery/master/utils/ImageDeepDetector.java

@@ -295,6 +295,13 @@ public class ImageDeepDetector {
 
     private static boolean isAcceptFile(XFile file) {
         try {
+            if (Objects.equals("8915a353c46c42a78a33bb9180fae9f5d7ca08392735469cb067b781cd464462.jpg", file.getName())) {
+                String path = file.getPath();
+            }
+        } catch (Exception e) {
+
+        }
+        try {
             if (file.length() == 0) {
                 return false;
             }
@@ -657,7 +664,8 @@ public class ImageDeepDetector {
                             path.contains("com.huawei.photos") ||
                             path.contains("DCIM") ||
                             path.contains("Pictures") ||
-                            path.contains(".RecycleBin")
+                            path.contains(".RecycleBin") ||
+                            path.contains(".photoShare")
             );
         }
     }