mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-16 20:00:36 +01:00
rescan items after copy/move too
This commit is contained in:
parent
4dff81bc4a
commit
f7d9fcedd3
@ -17,6 +17,7 @@ public class CopyTask extends AsyncTask<Pair<List<File>, File>, Void, Boolean> {
|
|||||||
private static final String TAG = CopyTask.class.getSimpleName();
|
private static final String TAG = CopyTask.class.getSimpleName();
|
||||||
|
|
||||||
private static WeakReference<CopyListener> mListener;
|
private static WeakReference<CopyListener> mListener;
|
||||||
|
private static File destinationDir;
|
||||||
|
|
||||||
public CopyTask(CopyListener listener) {
|
public CopyTask(CopyListener listener) {
|
||||||
mListener = new WeakReference<>(listener);
|
mListener = new WeakReference<>(listener);
|
||||||
@ -28,7 +29,7 @@ public class CopyTask extends AsyncTask<Pair<List<File>, File>, Void, Boolean> {
|
|||||||
final List<File> files = pair.first;
|
final List<File> files = pair.first;
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
try {
|
try {
|
||||||
final File destinationDir = new File(pair.second, file.getName());
|
destinationDir = new File(pair.second, file.getName());
|
||||||
copy(file, destinationDir);
|
copy(file, destinationDir);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -74,14 +75,14 @@ public class CopyTask extends AsyncTask<Pair<List<File>, File>, Void, Boolean> {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
listener.copySucceeded();
|
listener.copySucceeded(destinationDir);
|
||||||
} else {
|
} else {
|
||||||
listener.copyFailed();
|
listener.copyFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CopyListener {
|
public interface CopyListener {
|
||||||
void copySucceeded();
|
void copySucceeded(File destinationDir);
|
||||||
|
|
||||||
void copyFailed();
|
void copyFailed();
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currFile.renameTo(newFile)) {
|
if (currFile.renameTo(newFile)) {
|
||||||
rescanFolder(newFile);
|
rescanItem(newFile);
|
||||||
MediaScannerConnection.scanFile(getContext(), new String[]{currFile.getAbsolutePath(), newFile.getAbsolutePath()}, null, null);
|
MediaScannerConnection.scanFile(getContext(), new String[]{currFile.getAbsolutePath(), newFile.getAbsolutePath()}, null, null);
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
fillItems();
|
fillItems();
|
||||||
@ -478,7 +478,9 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||||||
new CopyTask(ItemsFragment.this).execute(pair);
|
new CopyTask(ItemsFragment.this).execute(pair);
|
||||||
} else {
|
} else {
|
||||||
for (File f : itemsToCopy) {
|
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();
|
mCopyDialog.dismiss();
|
||||||
@ -588,10 +590,10 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||||||
mToBeDeleted.clear();
|
mToBeDeleted.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rescanFolder(File item) {
|
private void rescanItem(File item) {
|
||||||
if (item.isDirectory()) {
|
if (item.isDirectory()) {
|
||||||
for (File child : item.listFiles()) {
|
for (File child : item.listFiles()) {
|
||||||
rescanFolder(child);
|
rescanItem(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +626,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copySucceeded() {
|
public void copySucceeded(File file) {
|
||||||
|
rescanItem(file);
|
||||||
mCopyDialog.dismiss();
|
mCopyDialog.dismiss();
|
||||||
fillItems();
|
fillItems();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user