|
@@ -11,6 +11,7 @@ import com.atmob.common.runtime.ContextUtil;
|
|
|
import com.datarecovery.master.R;
|
|
import com.datarecovery.master.R;
|
|
|
import com.datarecovery.master.utils.FileUtil;
|
|
import com.datarecovery.master.utils.FileUtil;
|
|
|
import com.datarecovery.master.utils.FilesSearch;
|
|
import com.datarecovery.master.utils.FilesSearch;
|
|
|
|
|
+import com.datarecovery.master.utils.ImageDeepDetector;
|
|
|
import com.datarecovery.master.utils.MediaStoreHelper;
|
|
import com.datarecovery.master.utils.MediaStoreHelper;
|
|
|
import com.datarecovery.master.utils.ToastUtil;
|
|
import com.datarecovery.master.utils.ToastUtil;
|
|
|
|
|
|
|
@@ -35,13 +36,12 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
private final String IS_SHOW_VIDEO_HINT = "isShowVideoHint";
|
|
private final String IS_SHOW_VIDEO_HINT = "isShowVideoHint";
|
|
|
private final long SCANNING_COUNTDOWN = 1000 * 60 * 6;
|
|
private final long SCANNING_COUNTDOWN = 1000 * 60 * 6;
|
|
|
- private LiveData<String> selectedCountTxt;
|
|
|
|
|
- private final MutableLiveData<Boolean> checkAll = new MutableLiveData<>();
|
|
|
|
|
- private final MutableLiveData<List<FilesSearch.DocumentFile>> detectedVideoList = new MutableLiveData<>();
|
|
|
|
|
- private final MutableLiveData<List<FilesSearch.DocumentFile>> selectedList = new MutableLiveData<>();
|
|
|
|
|
|
|
+ private final LiveData<String> selectedCountTxt;
|
|
|
|
|
+ private final MutableLiveData<Boolean> checkAll = new MutableLiveData<>(false);
|
|
|
|
|
+ private final MutableLiveData<List<FilesSearch.DocumentFile>> detectedVideoList = new MutableLiveData<>(new ArrayList<>());
|
|
|
|
|
+ private final MutableLiveData<List<FilesSearch.DocumentFile>> selectedList = new MutableLiveData<>(new ArrayList<>());
|
|
|
|
|
|
|
|
private final SingleLiveEvent<?> detectedFinish = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<?> detectedFinish = new SingleLiveEvent<>();
|
|
|
- private final SingleLiveEvent<?> finishEvent = new SingleLiveEvent<>();
|
|
|
|
|
private final SingleLiveEvent<Boolean> showScanDialogEvent = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<Boolean> showScanDialogEvent = new SingleLiveEvent<>();
|
|
|
private final SingleLiveEvent<Boolean> showLoadingEvent = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<Boolean> showLoadingEvent = new SingleLiveEvent<>();
|
|
|
private int totalCount = 0;
|
|
private int totalCount = 0;
|
|
@@ -76,10 +76,6 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
return detectedFinish;
|
|
return detectedFinish;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public LiveData<?> getFinishEvent() {
|
|
|
|
|
- return finishEvent;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public LiveData<Boolean> getShowScanDialogEvent() {
|
|
public LiveData<Boolean> getShowScanDialogEvent() {
|
|
|
return showScanDialogEvent;
|
|
return showScanDialogEvent;
|
|
|
}
|
|
}
|
|
@@ -100,13 +96,6 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
return selectedCountTxt;
|
|
return selectedCountTxt;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void onCheckAllClick(boolean isCheck) {
|
|
|
|
|
- if (!scanDisposable.isDisposed()) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- checkAll.setValue(isCheck);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
public LiveData<Boolean> getShowLoadingEvent() {
|
|
public LiveData<Boolean> getShowLoadingEvent() {
|
|
|
return showLoadingEvent;
|
|
return showLoadingEvent;
|
|
@@ -134,10 +123,7 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
}
|
|
}
|
|
|
totalCount += documentFiles.size();
|
|
totalCount += documentFiles.size();
|
|
|
totalDetectedCount.setValue(totalCount);
|
|
totalDetectedCount.setValue(totalCount);
|
|
|
- List<FilesSearch.DocumentFile> videoList = detectedVideoList.getValue();
|
|
|
|
|
- if (videoList == null) {
|
|
|
|
|
- videoList = new ArrayList<>();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<FilesSearch.DocumentFile> videoList = getList(detectedVideoList);
|
|
|
videoList.addAll(0, documentFiles);
|
|
videoList.addAll(0, documentFiles);
|
|
|
detectedVideoList.setValue(videoList);
|
|
detectedVideoList.setValue(videoList);
|
|
|
}
|
|
}
|
|
@@ -154,6 +140,34 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void onCheckAllClick(boolean isCheck) {
|
|
|
|
|
+ if (!scanDisposable.isDisposed()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ checkAll.setValue(isCheck);
|
|
|
|
|
+ List<FilesSearch.DocumentFile> detectedList = getList(detectedVideoList);
|
|
|
|
|
+ for (FilesSearch.DocumentFile videoFile : detectedList) {
|
|
|
|
|
+ videoFile.setCheck(isCheck);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<FilesSearch.DocumentFile> selectedList = getList(this.selectedList);
|
|
|
|
|
+ if (isCheck) {
|
|
|
|
|
+ selectedList.clear();
|
|
|
|
|
+ selectedList.addAll(detectedList);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ selectedList.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+ this.selectedList.setValue(selectedList);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<FilesSearch.DocumentFile> getList(LiveData<List<FilesSearch.DocumentFile>> liveData) {
|
|
|
|
|
+ List<FilesSearch.DocumentFile> selectList = liveData.getValue();
|
|
|
|
|
+ if (selectList == null) {
|
|
|
|
|
+ selectList = new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ return selectList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void cancelScan() {
|
|
public void cancelScan() {
|
|
|
if (scanDisposable != null) scanDisposable.dispose();
|
|
if (scanDisposable != null) scanDisposable.dispose();
|
|
|
}
|
|
}
|
|
@@ -185,10 +199,7 @@ public class VideoRecoverViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
public void setItemCheck(@NonNull FilesSearch.DocumentFile file) {
|
|
public void setItemCheck(@NonNull FilesSearch.DocumentFile file) {
|
|
|
file.setCheck(!file.isCheck());
|
|
file.setCheck(!file.isCheck());
|
|
|
- List<FilesSearch.DocumentFile> list = selectedList.getValue();
|
|
|
|
|
- if (list == null) {
|
|
|
|
|
- list = new ArrayList<>();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<FilesSearch.DocumentFile> list = getList(selectedList);
|
|
|
if (file.isCheck()) {
|
|
if (file.isCheck()) {
|
|
|
list.add(file);
|
|
list.add(file);
|
|
|
} else {
|
|
} else {
|