1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

[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:
Nikolay Minaylov
2023-07-12 19:35:11 +03:00
committed by GitHub
parent a4b4802897
commit 92c0baa461
4 changed files with 71 additions and 29 deletions

View File

@@ -248,24 +248,10 @@ View* archive_browser_get_view(ArchiveBrowserView* browser) {
return browser->view;
}
static bool 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;
static void file_list_rollover(ArchiveBrowserViewModel* model) {
if(!model->list_loading && files_array_size(model->files) < model->item_cnt) {
files_array_reset(model->files);
}
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;
}
static bool archive_view_input(InputEvent* event, void* context) {
@@ -347,12 +333,13 @@ static bool archive_view_input(InputEvent* event, void* context) {
if(model->item_idx < scroll_speed) {
model->button_held_for_ticks = 0;
model->item_idx = model->item_cnt - 1;
file_list_rollover(model);
} else {
model->item_idx =
((model->item_idx - scroll_speed) + model->item_cnt) %
model->item_cnt;
}
if(is_file_list_load_required(model)) {
if(archive_is_file_list_load_required(model)) {
model->list_loading = true;
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context);
}
@@ -366,10 +353,11 @@ static bool archive_view_input(InputEvent* event, void* context) {
if(model->item_idx + scroll_speed >= count) {
model->button_held_for_ticks = 0;
model->item_idx = 0;
file_list_rollover(model);
} else {
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
}
if(is_file_list_load_required(model)) {
if(archive_is_file_list_load_required(model)) {
model->list_loading = true;
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context);
}