mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
delete files from main screen more carefully, and not recursively
This commit is contained in:
parent
c7408fb9fe
commit
a5da407ed3
1 changed files with 16 additions and 3 deletions
|
@ -13,6 +13,7 @@ import android.provider.MediaStore;
|
|||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.provider.DocumentFile;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
|
@ -232,11 +233,14 @@ public class MainActivity extends SimpleActivity
|
|||
if (dir.exists()) {
|
||||
final File[] files = dir.listFiles();
|
||||
for (File f : files) {
|
||||
updatedFiles.add(f.getAbsolutePath());
|
||||
f.delete();
|
||||
if (f.isFile()) {
|
||||
updatedFiles.add(f.getAbsolutePath());
|
||||
deleteItem(f);
|
||||
}
|
||||
}
|
||||
updatedFiles.add(dir.getAbsolutePath());
|
||||
dir.delete();
|
||||
if (dir.listFiles().length == 0)
|
||||
deleteItem(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,6 +249,15 @@ public class MainActivity extends SimpleActivity
|
|||
mToBeDeleted.clear();
|
||||
}
|
||||
|
||||
private void deleteItem(File file) {
|
||||
if (Utils.Companion.needsStupidWritePermissions(this, file.getAbsolutePath())) {
|
||||
final DocumentFile document = Utils.Companion.getFileDocument(this, file.getAbsolutePath());
|
||||
document.delete();
|
||||
} else {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private View.OnClickListener undoDeletion = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
Loading…
Reference in a new issue