[FL-3383, FL-3413] Archive and file browser fixes (#2862)
* File browser: flickering and reload fixes * The same for archive browser
This commit is contained in:
@@ -64,8 +64,20 @@ static void
|
||||
if(!is_last) {
|
||||
archive_add_file_item(browser, is_folder, furi_string_get_cstr(item_path));
|
||||
} else {
|
||||
bool load_again = false;
|
||||
with_view_model(
|
||||
browser->view, ArchiveBrowserViewModel * model, { model->list_loading = false; }, true);
|
||||
browser->view,
|
||||
ArchiveBrowserViewModel * model,
|
||||
{
|
||||
model->list_loading = false;
|
||||
if(archive_is_file_list_load_required(model)) {
|
||||
load_again = true;
|
||||
}
|
||||
},
|
||||
true);
|
||||
if(load_again) {
|
||||
archive_file_array_load(browser, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +123,26 @@ bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool archive_is_file_list_load_required(ArchiveBrowserViewModel* model) {
|
||||
size_t array_size = files_array_size(model->files);
|
||||
|
||||
if((model->list_loading) || (array_size >= model->item_cnt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if((model->array_offset > 0) &&
|
||||
(model->item_idx < (model->array_offset + FILE_LIST_BUF_LEN / 4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(((model->array_offset + array_size) < model->item_cnt) &&
|
||||
(model->item_idx > (int32_t)(model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void archive_update_offset(ArchiveBrowserView* browser) {
|
||||
furi_assert(browser);
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ inline bool archive_is_known_app(ArchiveFileTypeEnum type) {
|
||||
}
|
||||
|
||||
bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx);
|
||||
bool archive_is_file_list_load_required(ArchiveBrowserViewModel* model);
|
||||
void archive_update_offset(ArchiveBrowserView* browser);
|
||||
void archive_update_focus(ArchiveBrowserView* browser, const char* target);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user