mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 14:28:00 +01:00
improve renaming directories
This commit is contained in:
parent
842776cedf
commit
375489a536
1 changed files with 23 additions and 7 deletions
|
@ -248,13 +248,16 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
final File newDir = new File(dir.getParent(), newDirName);
|
final File newDir = new File(dir.getParent(), newDirName);
|
||||||
|
|
||||||
if (dir.renameTo(newDir)) {
|
if (dir.renameTo(newDir)) {
|
||||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
actionMode.finish();
|
actionMode.finish();
|
||||||
final String[] newDirPath = new String[]{newDir.getAbsolutePath()};
|
final List<String> updatedFiles = new ArrayList<>();
|
||||||
MediaScannerConnection.scanFile(getApplicationContext(), newDirPath, null, MainActivity.this);
|
updatedFiles.add(dir.getAbsolutePath());
|
||||||
|
updatedFiles.add(newDir.getAbsolutePath());
|
||||||
|
|
||||||
|
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
||||||
|
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, MainActivity.this);
|
||||||
} else {
|
} else {
|
||||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||||
}
|
}
|
||||||
|
@ -329,13 +332,26 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanCompleted(String path, Uri uri) {
|
public void onScanCompleted(final String path, final Uri uri) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
dirs = new ArrayList<>(getDirectories().values());
|
final File dir = new File(path);
|
||||||
updateGridView();
|
if (dir.isDirectory()) {
|
||||||
gridView.requestLayout();
|
final List<String> updatedFiles = new ArrayList<>();
|
||||||
|
|
||||||
|
final File[] files = dir.listFiles();
|
||||||
|
for (File f : files) {
|
||||||
|
updatedFiles.add(f.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
||||||
|
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
||||||
|
|
||||||
|
dirs = new ArrayList<>(getDirectories().values());
|
||||||
|
updateGridView();
|
||||||
|
gridView.requestLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue