From 468ac32e27fb345e91eb12331d7e60ea747ab012 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 7 Nov 2019 23:16:55 +0800 Subject: [PATCH] up --- .../app/web/controller/BookshelfController.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt b/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt index d41d4117c..87bcb3e1c 100644 --- a/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt +++ b/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt @@ -2,9 +2,12 @@ package io.legado.app.web.controller import io.legado.app.App import io.legado.app.data.entities.Book +import io.legado.app.help.BookHelp +import io.legado.app.model.WebBook import io.legado.app.utils.GSON import io.legado.app.utils.fromJsonObject import io.legado.app.web.utils.ReturnData +import kotlinx.coroutines.runBlocking class BookshelfController { @@ -38,7 +41,22 @@ class BookshelfController { if (book == null || chapter == null) { returnData.setErrorMsg("未找到") } else { - + val content = BookHelp.getContent(book, chapter) + if (content != null) { + returnData.setData(content) + } else { + runBlocking { + App.db.bookSourceDao().getBookSource(book.origin)?.let { source -> + WebBook(source).getContent(book, chapter) + .onSuccess { + returnData.setData(it!!) + } + .onError { + returnData.setErrorMsg(it.localizedMessage) + } + } ?: returnData.setErrorMsg("未找到书源") + } + } } return returnData }