Async processing of thumbnails
This commit is contained in:
@@ -132,8 +132,8 @@ void HomeActivity::loadRecentBooks(int maxBooks) {
|
||||
void HomeActivity::loadRecentCovers(int coverHeight) {
|
||||
recentsLoading = true;
|
||||
|
||||
int progress = 0;
|
||||
for (RecentBook& book : recentBooks) {
|
||||
for (; nextRecentCoverIndex < recentBooks.size(); nextRecentCoverIndex++) {
|
||||
RecentBook& book = recentBooks[nextRecentCoverIndex];
|
||||
if (!book.coverBmpPath.empty()) {
|
||||
std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
|
||||
if (!Storage.exists(coverPath.c_str())) {
|
||||
@@ -150,7 +150,10 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
|
||||
book.coverBmpPath = "";
|
||||
}
|
||||
coverRendered = false;
|
||||
nextRecentCoverIndex++;
|
||||
recentsLoading = false;
|
||||
requestUpdate();
|
||||
return;
|
||||
} else if (FsHelpers::hasXtcExtension(book.path)) {
|
||||
// Handle XTC file
|
||||
Xtc xtc(book.path, "/.crosspoint");
|
||||
@@ -162,12 +165,14 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
|
||||
book.coverBmpPath = "";
|
||||
}
|
||||
coverRendered = false;
|
||||
nextRecentCoverIndex++;
|
||||
recentsLoading = false;
|
||||
requestUpdate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
progress++;
|
||||
}
|
||||
|
||||
recentsLoaded = true;
|
||||
@@ -181,9 +186,18 @@ void HomeActivity::onEnter() {
|
||||
hasOpdsUrl = strlen(SETTINGS.opdsServerUrl) > 0;
|
||||
|
||||
selectorIndex = 0;
|
||||
recentsLoading = false;
|
||||
recentsLoaded = false;
|
||||
firstRenderDone = false;
|
||||
nextRecentCoverIndex = 0;
|
||||
coverRendered = false;
|
||||
freeCoverBuffer();
|
||||
|
||||
const auto& metrics = UITheme::getInstance().getMetrics();
|
||||
loadRecentBooks(metrics.homeRecentBooksCount);
|
||||
if (recentBooks.empty()) {
|
||||
recentsLoaded = true;
|
||||
}
|
||||
|
||||
// Trigger first update
|
||||
requestUpdate();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
@@ -18,6 +19,7 @@ class HomeActivity final : public Activity {
|
||||
bool hasOpdsUrl = false;
|
||||
bool coverRendered = false; // Track if cover has been rendered once
|
||||
bool coverBufferStored = false; // Track if cover buffer is stored
|
||||
size_t nextRecentCoverIndex = 0;
|
||||
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
|
||||
std::vector<RecentBook> recentBooks;
|
||||
void onSelectBook(const std::string& path);
|
||||
|
||||
Reference in New Issue
Block a user