From c56587894b3b0915688a231fce158b34f6d06dde Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 21:33:35 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/data/dao/SearchBookDao.kt | 2 -- .../main/java/io/legado/app/model/webbook/BookList.kt | 6 +++--- .../app/ui/changesource/ChangeSourceViewModel.kt | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index a197b0e51..75e6ae895 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -35,6 +35,4 @@ interface SearchBookDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg searchBook: SearchBook): List - @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insert(searchBook: SearchBook): Long } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/webbook/BookList.kt b/app/src/main/java/io/legado/app/model/webbook/BookList.kt index 421d9cdd7..61e86f568 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookList.kt @@ -112,11 +112,11 @@ object BookList { } SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书名") searchBook.name = analyzeRule.getString(name ?: "") ?: "" - SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name ?: "") + SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name) if (searchBook.name.isNotEmpty()) { SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者") searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(author ?: "")) - SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author ?: "") + SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author) SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类") searchBook.kind = analyzeRule.getString(kind ?: "") SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "") @@ -169,7 +169,7 @@ object BookList { SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.bookUrl, printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者", printLog) searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(ruleAuthor)) - SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author ?: "", printLog) + SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author, printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类", printLog) searchBook.kind = analyzeRule.getString(ruleKind) SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "", printLog) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index f190fe973..998fab1e7 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -65,11 +65,11 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> WebBook(bookSource).getChapterList(book, this) .onSuccess(Dispatchers.IO) { - it?.let { - if (it.isNotEmpty()) { - book.latestChapterTitle = it.last().title - searchBooks.add(book.toSearchBook()) - } + it?.map { chapter -> + book.latestChapterTitle = chapter.title + val searchBook = book.toSearchBook() + searchBooks.add(searchBook) + App.db.searchBookDao().insert(searchBook) } }.onError { toast(R.string.error_get_chapter_list)