mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(extension): Prevent crashes related to extensions
Mostly to prevent "NetworkOnMainThreadException"
This commit is contained in:
parent
ba7baba449
commit
4d2909340e
5 changed files with 10 additions and 6 deletions
|
@ -10,4 +10,4 @@
|
||||||
## Other ?? Technical stuff, what happened behind the scene
|
## Other ?? Technical stuff, what happened behind the scene
|
||||||
-->
|
-->
|
||||||
## Fixes
|
## Fixes
|
||||||
- Fixed custom cover set from reader didn't show up on manga details
|
- Fixed crashes caused by certain extension implementation
|
||||||
|
|
|
@ -646,12 +646,13 @@ class Downloader(
|
||||||
) {
|
) {
|
||||||
val categories =
|
val categories =
|
||||||
db.getCategoriesForManga(manga).executeAsBlocking().map { it.name.trim() }.takeUnless { it.isEmpty() }
|
db.getCategoriesForManga(manga).executeAsBlocking().map { it.name.trim() }.takeUnless { it.isEmpty() }
|
||||||
val urls = source.getChapterUrl(manga, chapter)?.let { listOf(it) } ?: listOf()
|
val url = try { source.getChapterUrl(chapter) } catch (_: Exception) { null }
|
||||||
|
?: source.getChapterUrl(manga, chapter).takeIf { !it.isNullOrBlank() } // FIXME: Not sure if this is necessary
|
||||||
|
|
||||||
val comicInfo = getComicInfo(
|
val comicInfo = getComicInfo(
|
||||||
manga,
|
manga,
|
||||||
chapter,
|
chapter,
|
||||||
urls,
|
url?.let { listOf(it) } ?: listOf(),
|
||||||
categories,
|
categories,
|
||||||
source.name,
|
source.name,
|
||||||
source.lang,
|
source.lang,
|
||||||
|
|
|
@ -308,7 +308,8 @@ class MangaDetailsPresenter(
|
||||||
fun getChapterUrl(chapter: Chapter): String? {
|
fun getChapterUrl(chapter: Chapter): String? {
|
||||||
val source = source as? HttpSource ?: return null
|
val source = source as? HttpSource ?: return null
|
||||||
val chapterUrl = try { source.getChapterUrl(chapter) } catch (_: Exception) { null }
|
val chapterUrl = try { source.getChapterUrl(chapter) } catch (_: Exception) { null }
|
||||||
return chapterUrl.takeIf { !it.isNullOrBlank() } ?: source.getChapterUrl(manga, chapter)
|
return chapterUrl.takeIf { !it.isNullOrBlank() }
|
||||||
|
?: try { source.getChapterUrl(manga, chapter) } catch (_: Exception) { null }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getScrollType(chapters: List<ChapterItem>) {
|
private fun getScrollType(chapters: List<ChapterItem>) {
|
||||||
|
|
|
@ -682,7 +682,8 @@ class ReaderViewModel(
|
||||||
val source = getSource() ?: return null
|
val source = getSource() ?: return null
|
||||||
val chapter = mainChapter ?: getCurrentChapter()?.chapter ?: return null
|
val chapter = mainChapter ?: getCurrentChapter()?.chapter ?: return null
|
||||||
val chapterUrl = try { source.getChapterUrl(chapter) } catch (_: Exception) { null }
|
val chapterUrl = try { source.getChapterUrl(chapter) } catch (_: Exception) { null }
|
||||||
return chapterUrl.takeIf { !it.isNullOrBlank() } ?: source.getChapterUrl(manga, chapter)
|
return chapterUrl.takeIf { !it.isNullOrBlank() }
|
||||||
|
?: try { source.getChapterUrl(manga, chapter) } catch (_: Exception) { null }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSource() = manga?.source?.let { sourceManager.getOrStub(it) } as? HttpSource
|
fun getSource() = manga?.source?.let { sourceManager.getOrStub(it) } as? HttpSource
|
||||||
|
|
|
@ -448,9 +448,10 @@ abstract class HttpSource : CatalogueSource {
|
||||||
* @return url of the chapter
|
* @return url of the chapter
|
||||||
*/
|
*/
|
||||||
open fun getChapterUrl(chapter: SChapter): String {
|
open fun getChapterUrl(chapter: SChapter): String {
|
||||||
return ""
|
return pageListRequest(chapter).url.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Not sure if this is necessary, feels like this should be handled by the extension not by the app
|
||||||
fun getChapterUrl(manga: SManga?, chapter: SChapter): String? {
|
fun getChapterUrl(manga: SManga?, chapter: SChapter): String? {
|
||||||
manga ?: return null
|
manga ?: return null
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue