Fix file loading in ExplorerActivity

This commit is contained in:
William Brawner 2018-10-16 07:50:29 -05:00 committed by William Brawner
parent 087a7728e2
commit 909ea47a19

View file

@ -216,23 +216,25 @@ public class ExplorerActivity extends AppCompatActivity {
setTitle(filesDir.getName());
filePath.set(filesDir.getAbsolutePath());
fileHandler.post(() -> {
List<HashMap<String, Object>> files = loadFiles(filesDir);
final List<HashMap<String, Object>> files = loadFiles(filesDir);
listView.setAdapter(new SimpleAdapter(
this,
files,
android.R.layout.simple_list_item_1,
new String[]{"name"},
new int[]{android.R.id.text1}
));
runOnUiThread(() -> {
listView.setAdapter(new SimpleAdapter(
this,
files,
android.R.layout.simple_list_item_1,
new String[]{"name"},
new int[]{android.R.id.text1}
));
listView.setOnItemClickListener((parent, view, position, id) -> {
File clickedFile = (File) files.get(position).get("file");
if (clickedFile.isFile()) {
handleFileClick(clickedFile);
} else if (clickedFile.isDirectory()) {
updateListView(clickedFile);
}
listView.setOnItemClickListener((parent, view, position, id) -> {
File clickedFile = (File) files.get(position).get("file");
if (clickedFile.isFile()) {
handleFileClick(clickedFile);
} else if (clickedFile.isDirectory()) {
updateListView(clickedFile);
}
});
});
});
}