do not display photos currently being deleted

This commit is contained in:
tibbi 2016-06-02 23:31:44 +02:00
parent ac6ef1ea3f
commit 64cae1b25d
1 changed files with 7 additions and 1 deletions

View File

@ -49,6 +49,7 @@ public class ViewPagerActivity extends AppCompatActivity
private String directory; private String directory;
private boolean isUndoShown; private boolean isUndoShown;
private String toBeDeleted; private String toBeDeleted;
private String beingDeleted;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -60,6 +61,7 @@ public class ViewPagerActivity extends AppCompatActivity
isFullScreen = true; isFullScreen = true;
actionbar = getSupportActionBar(); actionbar = getSupportActionBar();
toBeDeleted = ""; toBeDeleted = "";
beingDeleted = "";
hideSystemUI(); hideSystemUI();
path = getIntent().getStringExtra(Constants.PHOTO); path = getIntent().getStringExtra(Constants.PHOTO);
@ -85,6 +87,7 @@ public class ViewPagerActivity extends AppCompatActivity
public void undoDeletion() { public void undoDeletion() {
isUndoShown = false; isUndoShown = false;
toBeDeleted = ""; toBeDeleted = "";
beingDeleted = "";
undoBtn.setVisibility(View.GONE); undoBtn.setVisibility(View.GONE);
reloadViewPager(); reloadViewPager();
} }
@ -142,9 +145,11 @@ public class ViewPagerActivity extends AppCompatActivity
return; return;
isUndoShown = false; isUndoShown = false;
beingDeleted = "";
final File file = new File(toBeDeleted); final File file = new File(toBeDeleted);
if (file.delete()) { if (file.delete()) {
beingDeleted = toBeDeleted;
final String[] deletedPath = new String[]{toBeDeleted}; final String[] deletedPath = new String[]{toBeDeleted};
MediaScannerConnection.scanFile(this, deletedPath, null, this); MediaScannerConnection.scanFile(this, deletedPath, null, this);
} }
@ -255,7 +260,7 @@ public class ViewPagerActivity extends AppCompatActivity
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA); final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
do { do {
final String curPath = cursor.getString(pathIndex); final String curPath = cursor.getString(pathIndex);
if (curPath.matches(pattern) && !curPath.equals(toBeDeleted)) { if (curPath.matches(pattern) && !curPath.equals(toBeDeleted) && !curPath.equals(beingDeleted)) {
photos.add(curPath); photos.add(curPath);
if (curPath.equals(path)) { if (curPath.equals(path)) {
@ -355,6 +360,7 @@ public class ViewPagerActivity extends AppCompatActivity
@Override @Override
public void onScanCompleted(String path, Uri uri) { public void onScanCompleted(String path, Uri uri) {
beingDeleted = "";
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {