MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / loadRecentCovers

Method loadRecentCovers

src/activities/home/HomeActivity.cpp:54–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void HomeActivity::loadRecentCovers(int coverHeight) {
55 recentsLoading = true;
56 bool showingLoading = false;
57 Rect popupRect;
58
59 int progress = 0;
60 for (RecentBook& book : recentBooks) {
61 if (!book.coverBmpPath.empty()) {
62 std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
63 if (!Storage.exists(coverPath.c_str())) {
64 // If epub, try to load the metadata for title/author and cover
65 if (FsHelpers::hasEpubExtension(book.path)) {
66 Epub epub(book.path, "/.crosspoint");
67 // Skip loading css since we only need metadata here
68 epub.load(false, true);
69
70 // Try to generate thumbnail image for Continue Reading card
71 if (!showingLoading) {
72 showingLoading = true;
73 popupRect = GUI.drawPopup(renderer, tr(STR_LOADING_POPUP));
74 }
75 GUI.fillPopupProgress(renderer, popupRect, 10 + progress * (90 / recentBooks.size()));
76 bool success = epub.generateThumbBmp(coverHeight);
77 if (!success) {
78 RECENT_BOOKS.updateBook(book.path, book.title, book.author, "");
79 book.coverBmpPath = "";
80 }
81 coverRendered = false;
82 requestUpdate();
83 } else if (FsHelpers::hasXtcExtension(book.path)) {
84 // Handle XTC file
85 Xtc xtc(book.path, "/.crosspoint");
86 if (xtc.load()) {
87 // Try to generate thumbnail image for Continue Reading card
88 if (!showingLoading) {
89 showingLoading = true;
90 popupRect = GUI.drawPopup(renderer, tr(STR_LOADING_POPUP));
91 }
92 GUI.fillPopupProgress(renderer, popupRect, 10 + progress * (90 / recentBooks.size()));
93 bool success = xtc.generateThumbBmp(coverHeight);
94 if (!success) {
95 RECENT_BOOKS.updateBook(book.path, book.title, book.author, "");
96 book.coverBmpPath = "";
97 }
98 coverRendered = false;
99 requestUpdate();
100 }
101 }
102 }
103 }
104 progress++;
105 }
106
107 recentsLoaded = true;
108 recentsLoading = false;
109}
110
111void HomeActivity::onEnter() {

Callers

nothing calls this directly

Calls 10

hasXtcExtensionFunction · 0.85
existsMethod · 0.80
drawPopupMethod · 0.80
fillPopupProgressMethod · 0.80
updateBookMethod · 0.80
hasEpubExtensionFunction · 0.50
emptyMethod · 0.45
loadMethod · 0.45
sizeMethod · 0.45
generateThumbBmpMethod · 0.45

Tested by

no test coverage detected