diff --git a/app/src/main/java/com/simplemobiletools/filemanager/asynctasks/CopyTask.java b/app/src/main/java/com/simplemobiletools/filemanager/asynctasks/CopyTask.java index fd26dda4..f282f48e 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/asynctasks/CopyTask.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/asynctasks/CopyTask.java @@ -17,6 +17,7 @@ public class CopyTask extends AsyncTask, File>, Void, Boolean> { private static final String TAG = CopyTask.class.getSimpleName(); private static WeakReference mListener; + private static File destinationDir; public CopyTask(CopyListener listener) { mListener = new WeakReference<>(listener); @@ -28,7 +29,7 @@ public class CopyTask extends AsyncTask, File>, Void, Boolean> { final List files = pair.first; for (File file : files) { try { - final File destinationDir = new File(pair.second, file.getName()); + destinationDir = new File(pair.second, file.getName()); copy(file, destinationDir); return true; } catch (Exception e) { @@ -74,14 +75,14 @@ public class CopyTask extends AsyncTask, File>, Void, Boolean> { return; if (success) { - listener.copySucceeded(); + listener.copySucceeded(destinationDir); } else { listener.copyFailed(); } } public interface CopyListener { - void copySucceeded(); + void copySucceeded(File destinationDir); void copyFailed(); } diff --git a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java index 3a719b79..cdec91f9 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -414,7 +414,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment } if (currFile.renameTo(newFile)) { - rescanFolder(newFile); + rescanItem(newFile); MediaScannerConnection.scanFile(getContext(), new String[]{currFile.getAbsolutePath(), newFile.getAbsolutePath()}, null, null); alertDialog.dismiss(); fillItems(); @@ -478,7 +478,9 @@ public class ItemsFragment extends android.support.v4.app.Fragment new CopyTask(ItemsFragment.this).execute(pair); } else { for (File f : itemsToCopy) { - f.renameTo(new File(destinationDir, f.getName())); + final File destination = new File(destinationDir, f.getName()); + f.renameTo(destination); + rescanItem(destination); } mCopyDialog.dismiss(); @@ -588,10 +590,10 @@ public class ItemsFragment extends android.support.v4.app.Fragment mToBeDeleted.clear(); } - private void rescanFolder(File item) { + private void rescanItem(File item) { if (item.isDirectory()) { for (File child : item.listFiles()) { - rescanFolder(child); + rescanItem(child); } } @@ -624,7 +626,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment } @Override - public void copySucceeded() { + public void copySucceeded(File file) { + rescanItem(file); mCopyDialog.dismiss(); fillItems(); }