diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 9590a1fcf..ed8d2f51c 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -51,8 +51,7 @@ import butterknife.ButterKnife; public class MainActivity extends SimpleActivity implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, - SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener, GetDirectoriesAsynctask.GetDirectoriesListener, - CopyMoveTask.CopyMoveListener { + SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener, GetDirectoriesAsynctask.GetDirectoriesListener { @BindView(R.id.directories_grid) GridView mGridView; @BindView(R.id.directories_holder) SwipeRefreshLayout mSwipeRefreshLayout; @@ -331,7 +330,19 @@ public class MainActivity extends SimpleActivity } } - new CopyDialog(this, files, this); + new CopyDialog(this, files, new CopyMoveTask.CopyMoveListener() { + @Override + public void copySucceeded(boolean deleted) { + if (deleted) + getDirectories(); + Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); + } + + @Override + public void copyFailed() { + Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); + } + }); } private boolean isPickImageIntent(Intent intent) { @@ -584,15 +595,4 @@ public class MainActivity extends SimpleActivity mGridView.setOnTouchListener(this); mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL); } - - @Override - public void copySucceeded(boolean deleted) { - getDirectories(); - Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); - } - - @Override - public void copyFailed() { - Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); - } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index 8f5458493..27590d129 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -51,7 +51,7 @@ import butterknife.ButterKnife; public class MediaActivity extends SimpleActivity implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, - SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener, CopyMoveTask.CopyMoveListener { + SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener { private static final String TAG = MediaActivity.class.getSimpleName(); @BindView(R.id.media_grid) GridView mGridView; @BindView(R.id.media_holder) SwipeRefreshLayout mSwipeRefreshLayout; @@ -415,7 +415,19 @@ public class MediaActivity extends SimpleActivity } } - new CopyDialog(this, files, this); + new CopyDialog(this, files, new CopyMoveTask.CopyMoveListener() { + @Override + public void copySucceeded(boolean deleted) { + if (deleted) + refreshDir(); + Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); + } + + @Override + public void copyFailed() { + Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); + } + }); } @Override @@ -519,6 +531,10 @@ public class MediaActivity extends SimpleActivity @Override public void onRefresh() { + refreshDir(); + } + + private void refreshDir() { final File dir = new File(mPath); if (dir.isDirectory()) { Utils.Companion.scanPath(getApplicationContext(), mPath); @@ -531,14 +547,4 @@ public class MediaActivity extends SimpleActivity public void sortingDialogClosed() { initializeGallery(); } - - @Override - public void copySucceeded(boolean deleted) { - Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); - } - - @Override - public void copyFailed() { - Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); - } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 2c4820a7b..5be8ca145 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -43,7 +43,7 @@ import butterknife.OnClick; public class ViewPagerActivity extends SimpleActivity implements ViewPager.OnPageChangeListener, View.OnSystemUiVisibilityChangeListener, ViewPager.OnTouchListener, - ViewPagerFragment.FragmentClickListener, CopyMoveTask.CopyMoveListener { + ViewPagerFragment.FragmentClickListener { @BindView(R.id.undo_delete) View mUndoBtn; @BindView(R.id.view_pager) MyViewPager mPager; @@ -190,7 +190,19 @@ public class ViewPagerActivity extends SimpleActivity final File file = getCurrentFile(); final ArrayList files = new ArrayList<>(); files.add(file); - new CopyDialog(this, files, this); + new CopyDialog(this, files, new CopyMoveTask.CopyMoveListener() { + @Override + public void copySucceeded(boolean deleted) { + if (deleted) + reloadViewPager(); + Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); + } + + @Override + public void copyFailed() { + Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); + } + }); } private void openEditor() { @@ -495,14 +507,4 @@ public class ViewPagerActivity extends SimpleActivity super.onPause(); deleteFile(); } - - @Override - public void copySucceeded(boolean deleted) { - Utils.Companion.showToast(getApplicationContext(), deleted ? R.string.moving_success : R.string.copying_success); - } - - @Override - public void copyFailed() { - Utils.Companion.showToast(getApplicationContext(), R.string.copying_failed); - } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt index dac7684ba..297f806a8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt @@ -94,7 +94,6 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList, val c } context.scanFiles(updatedFiles) {} - context.toast(R.string.moving_success) dismiss() copyMoveListener.copySucceeded(true) }