Merge pull request #94 from euquiq/fix-fileman-freeze-no-or-empty-sd

Fixes File manager freezing on absent or empty SD
This commit is contained in:
Erwin Ried 2020-08-03 00:35:47 +02:00 committed by GitHub
commit e7de39d130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,31 +92,37 @@ FileManBaseView::FileManBaseView(
) : nav_ (nav),
extension_filter { filter }
{
load_directory_contents(current_path);
if (!entry_list.size())
empty_root = true;
add_children({
&labels,
&text_current,
&button_exit
});
button_exit.on_select = [this, &nav](Button&) {
nav.pop();
};
if (!sdcIsCardInserted(&SDCD1)) {
empty_root=true;
text_current.set("NO SD CARD!");
} else {
load_directory_contents(current_path);
if (!entry_list.size())
{
empty_root = true;
text_current.set("EMPTY SD CARD!");
} else {
menu_view.on_left = [&nav, this]() {
load_directory_contents(get_parent_dir());
refresh_list();
};
button_exit.on_select = [this, &nav](Button&) {
nav.pop();
};
};
}
}
}
void FileManBaseView::focus() {
if (empty_root) {
button_exit.focus();
nav_.display_modal("Error", "No files in root.", ABORT, nullptr);
} else {
menu_view.focus();
}
@ -190,7 +196,6 @@ void FileManBaseView::refresh_list() {
nav_.pop();
});
}
FileSaveView::FileSaveView(
NavigationView& nav
) : FileManBaseView(nav)
@ -271,6 +276,7 @@ FileManagerView::FileManagerView(
NavigationView& nav
) : FileManBaseView(nav, "")
{
if (!empty_root) {
on_refresh_widgets = [this](bool v) {
refresh_widgets(v);
};
@ -322,6 +328,7 @@ FileManagerView::FileManagerView(
}
);
};
}
}
}