mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-22 13:34:49 +01:00
switch to the main thread only when doing UI things
This commit is contained in:
parent
af61d30113
commit
55dde5e80a
@ -334,27 +334,28 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanCompleted(final String path, final Uri uri) {
|
public void onScanCompleted(final String path, final Uri uri) {
|
||||||
runOnUiThread(new Runnable() {
|
final File dir = new File(path);
|
||||||
@Override
|
if (dir.isDirectory()) {
|
||||||
public void run() {
|
final List<String> updatedFiles = new ArrayList<>();
|
||||||
final File dir = new File(path);
|
|
||||||
if (dir.isDirectory()) {
|
|
||||||
final List<String> updatedFiles = new ArrayList<>();
|
|
||||||
|
|
||||||
final File[] files = dir.listFiles();
|
final File[] files = dir.listFiles();
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
updatedFiles.add(f.getAbsolutePath());
|
updatedFiles.add(f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
||||||
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, null);
|
||||||
|
|
||||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
dirs = new ArrayList<>(getDirectories().values());
|
||||||
dirs = new ArrayList<>(getDirectories().values());
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
updateGridView();
|
updateGridView();
|
||||||
gridView.requestLayout();
|
gridView.requestLayout();
|
||||||
|
Utils.showToast(getApplicationContext(), R.string.rename_folder_ok);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user