switch to the main thread only when doing UI things

This commit is contained in:
tibbi 2016-04-01 23:22:06 +02:00
parent af61d30113
commit 55dde5e80a

View file

@ -334,9 +334,6 @@ 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() {
@Override
public void run() {
final File dir = new File(path); final File dir = new File(path);
if (dir.isDirectory()) { if (dir.isDirectory()) {
final List<String> updatedFiles = new ArrayList<>(); final List<String> updatedFiles = new ArrayList<>();
@ -349,12 +346,16 @@ public class MainActivity extends AppCompatActivity
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);
} }
}); });
} }
} }
}