make sure we delete the proper checked folders
This commit is contained in:
parent
b880912ecb
commit
e4127b61d9
|
@ -132,13 +132,17 @@ public class MainActivity extends AppCompatActivity
|
|||
Helpers.showToast(this, R.string.deleting);
|
||||
final SparseBooleanArray items = gridView.getCheckedItemPositions();
|
||||
int cnt = items.size();
|
||||
int deletedCnt = 0;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
if (items.valueAt(i)) {
|
||||
final int id = items.keyAt(i);
|
||||
final String path = dirs.get(id).getPath();
|
||||
toBeDeleted.add(path);
|
||||
deletedCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
notifyDeletion(cnt);
|
||||
notifyDeletion(deletedCnt);
|
||||
}
|
||||
|
||||
private void notifyDeletion(int cnt) {
|
||||
|
@ -168,6 +172,7 @@ public class MainActivity extends AppCompatActivity
|
|||
final List<String> updatedFiles = new ArrayList<>();
|
||||
for (String delPath : toBeDeleted) {
|
||||
final File dir = new File(delPath);
|
||||
if (dir.exists()) {
|
||||
final File[] files = dir.listFiles();
|
||||
for (File f : files) {
|
||||
updatedFiles.add(f.getAbsolutePath());
|
||||
|
@ -176,6 +181,7 @@ public class MainActivity extends AppCompatActivity
|
|||
updatedFiles.add(dir.getAbsolutePath());
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
|
||||
final String[] deletedPaths = updatedFiles.toArray(new String[updatedFiles.size()]);
|
||||
MediaScannerConnection.scanFile(this, deletedPaths, null, null);
|
||||
|
|
|
@ -149,13 +149,17 @@ public class PhotosActivity extends AppCompatActivity
|
|||
Helpers.showToast(this, R.string.deleting);
|
||||
final SparseBooleanArray items = gridView.getCheckedItemPositions();
|
||||
int cnt = items.size();
|
||||
int deletedCnt = 0;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
if (items.valueAt(i)) {
|
||||
final int id = items.keyAt(i);
|
||||
final String path = photos.get(id);
|
||||
toBeDeleted.add(path);
|
||||
deletedCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
notifyDeletion(cnt);
|
||||
notifyDeletion(deletedCnt);
|
||||
}
|
||||
|
||||
private void notifyDeletion(int cnt) {
|
||||
|
|
Loading…
Reference in New Issue