Skip to content

Commit d48b4c3

Browse files
committed
fix(manga/details): NPE on tablets
1 parent 515a96e commit d48b4c3

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,4 @@
1010
## Other ?? Technical stuff, what happened behind the scene
1111
-->
1212
## Fixes
13-
- Fixed crashes caused by certain extension implementation
14-
- Fixed "Theme buttons based on cover" doesn't work properly
15-
- Fixed library cover images looks blurry then become sharp after going to
16-
entry's detail screen
17-
18-
## Other
19-
- More StorIO to SQLDelight migration effort
20-
- Update dependency dev.chrisbanes.compose:compose-bom to v2024.08.00-alpha02
21-
- Update kotlin monorepo to v2.0.20
22-
- Update aboutlibraries to v11.2.3
23-
- Remove dependency com.github.leandroBorgesFerreira:LoadingButtonAndroid
13+
- Fixed NPE crash on tablets

app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ class MangaDetailsPresenter(
147147

148148
val headerItem: MangaHeaderItem by lazy { MangaHeaderItem(mangaId, view?.fromCatalogue == true)}
149149
var tabletChapterHeaderItem: MangaHeaderItem? = null
150+
get() {
151+
when (view?.isTablet) {
152+
true -> if (field == null) {
153+
field = MangaHeaderItem(mangaId, false).apply {
154+
isChapterHeader = true
155+
}
156+
}
157+
else -> if (field != null) {
158+
field = null
159+
}
160+
}
161+
return field
162+
}
150163
private set
151164

152165
var allChapterScanlators: Set<String> = emptySet()
@@ -160,11 +173,6 @@ class MangaDetailsPresenter(
160173

161174
downloadManager.addListener(this)
162175

163-
LibraryUpdateJob.updateFlow
164-
.filter { it == mangaId }
165-
.onEach { onUpdateManga() }
166-
.launchIn(presenterScope)
167-
168176
tracks = db.getTracks(manga).executeAsBlocking()
169177
}
170178

@@ -174,6 +182,11 @@ class MangaDetailsPresenter(
174182
fun onCreateLate() {
175183
val controller = view ?: return
176184

185+
LibraryUpdateJob.updateFlow
186+
.filter { it == mangaId }
187+
.onEach { onUpdateManga() }
188+
.launchIn(presenterScope)
189+
177190
if (manga.isLocal()) {
178191
refreshAll()
179192
} else if (!manga.initialized) {
@@ -220,11 +233,6 @@ class MangaDetailsPresenter(
220233
isTablet = view?.isTablet == true
221234
isLocked = isLockedFromSearch
222235
}
223-
if (view?.isTablet == true) {
224-
tabletChapterHeaderItem = MangaHeaderItem(mangaId, false).apply {
225-
isChapterHeader = true
226-
}
227-
}
228236
}
229237

230238
suspend fun getChaptersNow(): List<ChapterItem> {

0 commit comments

Comments
 (0)