From e719d3d45725cbdf5afbe024a6e4ec63855ed06c Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 8 Apr 2026 14:43:16 +0200 Subject: [PATCH] Put things out of loop --- src/activities/home/HomeActivity.cpp | 24 ++++++++------------ src/activities/reader/EpubReaderActivity.cpp | 5 +--- src/activities/reader/TxtReaderActivity.cpp | 5 +--- src/activities/weather/WeatherActivity.cpp | 5 +--- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index 59080969..730fbc8a 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -131,8 +131,6 @@ void HomeActivity::loadRecentBooks(int maxBooks) { void HomeActivity::loadRecentCovers(int coverHeight) { recentsLoading = true; - bool showingLoading = false; - Rect popupRect; int progress = 0; for (RecentBook& book : recentBooks) { @@ -146,11 +144,6 @@ void HomeActivity::loadRecentCovers(int coverHeight) { epub.load(false, true); // Try to generate thumbnail image for Continue Reading card - if (!showingLoading) { - showingLoading = true; - popupRect = GUI.drawPopup(renderer, tr(STR_LOADING_POPUP)); - } - GUI.fillPopupProgress(renderer, popupRect, 10 + progress * (90 / recentBooks.size())); bool success = epub.generateThumbBmp(coverHeight); if (!success) { RECENT_BOOKS.updateBook(book.path, book.title, book.author, book.series, ""); @@ -163,11 +156,6 @@ void HomeActivity::loadRecentCovers(int coverHeight) { Xtc xtc(book.path, "/.crosspoint"); if (xtc.load()) { // Try to generate thumbnail image for Continue Reading card - if (!showingLoading) { - showingLoading = true; - popupRect = GUI.drawPopup(renderer, tr(STR_LOADING_POPUP)); - } - GUI.fillPopupProgress(renderer, popupRect, 10 + progress * (90 / recentBooks.size())); bool success = xtc.generateThumbBmp(coverHeight); if (!success) { RECENT_BOOKS.updateBook(book.path, book.title, book.author, book.series, ""); @@ -251,6 +239,15 @@ void HomeActivity::freeCoverBuffer() { } void HomeActivity::loop() { + if (firstRenderDone && !recentsLoaded && !recentsLoading) { + const auto& metrics = UITheme::getInstance().getMetrics(); + const Rect contentRect = UITheme::getContentRect(renderer, true, false); + const int menuItemCount = hasOpdsUrl ? 6 : 5; + const HomeScreenLayout layout = computeHomeScreenLayout(metrics, contentRect.height, menuItemCount); + loadRecentCovers(getHomeCoverRenderHeight(layout)); + return; + } + const int menuCount = getMenuItemCount(); buttonNavigator.onNext([this, menuCount] { @@ -336,9 +333,6 @@ void HomeActivity::render(RenderLock&&) { if (!firstRenderDone) { firstRenderDone = true; requestUpdate(); - } else if (!recentsLoaded && !recentsLoading) { - recentsLoading = true; - loadRecentCovers(getHomeCoverRenderHeight(layout)); } } diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 8bf48f9d..75dd6750 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -110,10 +110,7 @@ void EpubReaderActivity::onExit() { Activity::onExit(); // Reset orientation back to portrait for the rest of the UI - { - RenderLock lock(*this); - renderer.setOrientation(GfxRenderer::Orientation::Portrait); - } + renderer.setOrientation(GfxRenderer::Orientation::Portrait); APP_STATE.readerActivityLoadCount = 0; APP_STATE.saveToFile(); diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index b328a7dc..0df0fe1e 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -114,10 +114,7 @@ void TxtReaderActivity::onExit() { Activity::onExit(); // Reset orientation back to portrait for the rest of the UI - { - RenderLock lock(*this); - renderer.setOrientation(GfxRenderer::Orientation::Portrait); - } + renderer.setOrientation(GfxRenderer::Orientation::Portrait); pageOffsets.clear(); currentPageLines.clear(); diff --git a/src/activities/weather/WeatherActivity.cpp b/src/activities/weather/WeatherActivity.cpp index 51e2ec96..eb0830e9 100644 --- a/src/activities/weather/WeatherActivity.cpp +++ b/src/activities/weather/WeatherActivity.cpp @@ -220,10 +220,7 @@ void WeatherActivity::onExit() { Activity::onExit(); // Weather screen is always landscape; restore app UI to portrait on exit. - { - RenderLock lock(*this); - renderer.setOrientation(GfxRenderer::Orientation::Portrait); - } + renderer.setOrientation(GfxRenderer::Orientation::Portrait); WiFi.mode(WIFI_OFF); }