feat: show loading popup in BookInfo when parsing unopened book
When BookInfo is opened for a book with no existing cache, epub.load(true, true) triggers a 1-2s full parse. Show a "Loading..." popup with progress bar so the device doesn't appear frozen. Popup only appears on the fallback path — cached books load silently. Same pattern for XTC books. Made-with: Cursor
This commit is contained in:
@@ -63,32 +63,48 @@ void BookInfoActivity::onEnter() {
|
||||
|
||||
if (FsHelpers::hasEpubExtension(fileName)) {
|
||||
Epub epub(filePath, "/.crosspoint");
|
||||
if (!epub.load(false, true)) {
|
||||
bool needsBuild = !epub.load(false, true);
|
||||
Rect popupRect{};
|
||||
if (needsBuild) {
|
||||
popupRect = GUI.drawPopup(renderer, tr(STR_LOADING));
|
||||
GUI.fillPopupProgress(renderer, popupRect, 10);
|
||||
epub.load(true, true);
|
||||
GUI.fillPopupProgress(renderer, popupRect, 50);
|
||||
}
|
||||
{
|
||||
title = epub.getTitle();
|
||||
author = epub.getAuthor();
|
||||
series = epub.getSeries();
|
||||
seriesIndex = epub.getSeriesIndex();
|
||||
description = normalizeWhitespace(epub.getDescription());
|
||||
language = epub.getLanguage();
|
||||
|
||||
const int coverH = renderer.getScreenHeight() * 2 / 5;
|
||||
if (epub.generateThumbBmp(coverH)) {
|
||||
coverBmpPath = epub.getThumbBmpPath(coverH);
|
||||
} else {
|
||||
const int thumbW = static_cast<int>(coverH * 0.6);
|
||||
const std::string placeholderPath = epub.getCachePath() + "/placeholder_" + std::to_string(coverH) + ".bmp";
|
||||
if (PlaceholderCoverGenerator::generate(placeholderPath, title.empty() ? fileName : title, author, thumbW,
|
||||
coverH)) {
|
||||
coverBmpPath = placeholderPath;
|
||||
}
|
||||
title = epub.getTitle();
|
||||
author = epub.getAuthor();
|
||||
series = epub.getSeries();
|
||||
seriesIndex = epub.getSeriesIndex();
|
||||
description = normalizeWhitespace(epub.getDescription());
|
||||
language = epub.getLanguage();
|
||||
|
||||
const int coverH = renderer.getScreenHeight() * 2 / 5;
|
||||
if (epub.generateThumbBmp(coverH)) {
|
||||
coverBmpPath = epub.getThumbBmpPath(coverH);
|
||||
} else {
|
||||
const int thumbW = static_cast<int>(coverH * 0.6);
|
||||
const std::string placeholderPath = epub.getCachePath() + "/placeholder_" + std::to_string(coverH) + ".bmp";
|
||||
if (PlaceholderCoverGenerator::generate(placeholderPath, title.empty() ? fileName : title, author, thumbW,
|
||||
coverH)) {
|
||||
coverBmpPath = placeholderPath;
|
||||
}
|
||||
}
|
||||
if (needsBuild) {
|
||||
GUI.fillPopupProgress(renderer, popupRect, 100);
|
||||
}
|
||||
} else if (FsHelpers::hasXtcExtension(fileName)) {
|
||||
Xtc xtc(filePath, "/.crosspoint");
|
||||
bool needsBuild = !Storage.exists(xtc.getCachePath().c_str());
|
||||
Rect popupRect{};
|
||||
if (needsBuild) {
|
||||
popupRect = GUI.drawPopup(renderer, tr(STR_LOADING));
|
||||
GUI.fillPopupProgress(renderer, popupRect, 10);
|
||||
}
|
||||
if (xtc.load()) {
|
||||
if (needsBuild) {
|
||||
GUI.fillPopupProgress(renderer, popupRect, 50);
|
||||
}
|
||||
title = xtc.getTitle();
|
||||
author = xtc.getAuthor();
|
||||
|
||||
@@ -104,6 +120,9 @@ void BookInfoActivity::onEnter() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needsBuild) {
|
||||
GUI.fillPopupProgress(renderer, popupRect, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if (title.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user