|
|
@@ -8,8 +8,10 @@ import android.os.CancellationSignal;
|
|
|
import android.os.PowerManager;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
+import androidx.annotation.NonNull;
|
|
|
import androidx.databinding.BaseObservable;
|
|
|
import androidx.databinding.Bindable;
|
|
|
+import androidx.documentfile.provider.DocumentFile;
|
|
|
|
|
|
import com.datarecovery.master.BR;
|
|
|
import com.datarecovery.master.utils.filedetect.FileScanHelper;
|
|
|
@@ -41,36 +43,36 @@ public class FilesSearch {
|
|
|
CancellationSignal cancellationSignal = XFileSearch.searchPreExternalStorageAsync(context, FileScanHelper.getPreScanFileRelatedDirectory(),
|
|
|
new XFileSearch.FileFilter() {
|
|
|
|
|
|
- @Override
|
|
|
- public boolean acceptFile(XFile file) {
|
|
|
- return isAcceptFile(file);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean acceptDirectory(XFile file) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean filterDirectory(XFile file) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }, new XFileSearch.FileSearchCallback() {
|
|
|
- @Override
|
|
|
- public void onStart() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onEachFile(XFile file) {
|
|
|
- emitter.onNext(file);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- emitter.onComplete();
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public boolean acceptFile(XFile file) {
|
|
|
+ return isAcceptFile(file);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean acceptDirectory(XFile file) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean filterDirectory(XFile file) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }, new XFileSearch.FileSearchCallback() {
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onEachFile(XFile file) {
|
|
|
+ emitter.onNext(file);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ emitter.onComplete();
|
|
|
+ }
|
|
|
+ });
|
|
|
emitter.setCancellable(cancellationSignal::cancel);
|
|
|
} catch (Exception e) {
|
|
|
emitter.onError(e);
|
|
|
@@ -114,6 +116,9 @@ public class FilesSearch {
|
|
|
return false;
|
|
|
}
|
|
|
try {
|
|
|
+ if (!file.isDirectory() && file.length() == 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
String name = file.getName();
|
|
|
if (TextUtils.isEmpty(name)) {
|
|
|
return false;
|
|
|
@@ -282,5 +287,22 @@ public class FilesSearch {
|
|
|
public boolean delete() throws Exception {
|
|
|
return xFile.delete();
|
|
|
}
|
|
|
+
|
|
|
+ @NonNull
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "DocumentFile{" +
|
|
|
+ "xFile=" + xFile +
|
|
|
+ ", category=" + category +
|
|
|
+ ", name='" + name + '\'' +
|
|
|
+ ", size=" + size +
|
|
|
+ ", uri=" + uri +
|
|
|
+ ", path='" + path + '\'' +
|
|
|
+ ", sizeDescribe='" + sizeDescribe + '\'' +
|
|
|
+ ", isCheck=" + isCheck +
|
|
|
+ ", lastModified=" + lastModified +
|
|
|
+ ", isTrial=" + isTrial +
|
|
|
+ '}';
|
|
|
+ }
|
|
|
}
|
|
|
}
|