plugins: properties: delay UI viewport update

Looks a little nicer whenever loading takes
less than 0.5s

Change-Id: Ied6c03fa8b06009f442d8c51aeaa49ad09b89db1
This commit is contained in:
Christian Soffke 2024-07-30 19:00:30 +02:00
parent e3097bf92c
commit a430120b3f

View file

@ -199,13 +199,10 @@ static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"};
static void display_dir_stats_vp(struct dir_stats *stats, struct viewport *vp,
struct screen *display)
{
static bool initialized;
int32_t lang_size_unit;
unsigned long display_size = human_size(stats->byte_count, &lang_size_unit);
struct viewport *last_vp = display->set_viewport(vp);
display->clear_viewport();
if (initialized)
{
display->putsf(0, 0, "Files: %d (%lu %s)", stats->file_count,
display_size, rb->str(lang_size_unit));
display->putsf(0, 1, "Audio: %d", stats->audio_file_count);
@ -219,9 +216,6 @@ static void display_dir_stats_vp(struct dir_stats *stats, struct viewport *vp,
}
else
display->putsf(0, 2, "Directories: %d", stats->dir_count);
}
else
initialized = true;
display->update_viewport();
display->set_viewport(last_vp);
@ -274,6 +268,7 @@ bool collect_dir_stats(struct dir_stats *stats, bool (*id3_cb)(const char*))
stats->dir_count++; /* new directory */
if (*rb->current_tick - last_displayed > (HZ/2))
{
if (last_displayed)
display_dir_stats(stats);
last_displayed = *(rb->current_tick);
}