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)