pull/32/head
kunfei 5 years ago
parent 2c51e1453f
commit c56587894b
  1. 2
      app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt
  2. 6
      app/src/main/java/io/legado/app/model/webbook/BookList.kt
  3. 10
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -35,6 +35,4 @@ interface SearchBookDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg searchBook: SearchBook): List<Long>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(searchBook: SearchBook): Long
}

@ -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)

@ -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)

Loading…
Cancel
Save