hide the snackbar when paused too
This commit is contained in:
parent
b8f4bcbd0a
commit
2c86b0fb1c
|
@ -60,6 +60,12 @@ public class PhotosActivity extends AppCompatActivity
|
||||||
tryloadGallery();
|
tryloadGallery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
deleteFiles();
|
||||||
|
}
|
||||||
|
|
||||||
private void tryloadGallery() {
|
private void tryloadGallery() {
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||||
initializeGallery();
|
initializeGallery();
|
||||||
|
@ -148,7 +154,6 @@ public class PhotosActivity extends AppCompatActivity
|
||||||
toBeDeleted.add(photos.get(id));
|
toBeDeleted.add(photos.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDeletion(toBeDeleted.size());
|
|
||||||
MediaScannerConnection.scanFile(this, new String[]{path}, null, this);
|
MediaScannerConnection.scanFile(this, new String[]{path}, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +168,12 @@ public class PhotosActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFiles() {
|
private void deleteFiles() {
|
||||||
|
if (snackbar == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
snackbar.dismiss();
|
||||||
|
isSnackbarShown = false;
|
||||||
|
|
||||||
for (String delPath : toBeDeleted) {
|
for (String delPath : toBeDeleted) {
|
||||||
final File file = new File(delPath);
|
final File file = new File(delPath);
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
|
@ -242,6 +253,7 @@ public class PhotosActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateGridView();
|
updateGridView();
|
||||||
|
notifyDeletion(toBeDeleted.size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -250,8 +262,6 @@ public class PhotosActivity extends AppCompatActivity
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if (isSnackbarShown) {
|
if (isSnackbarShown) {
|
||||||
deleteFiles();
|
deleteFiles();
|
||||||
snackbar.dismiss();
|
|
||||||
isSnackbarShown = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue