pull/32/head
kunfei 5 years ago
parent 56671dab43
commit f1d5d0330d
  1. 16
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 26
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  3. 3
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -89,4 +89,20 @@ data class Book(
} }
return kindList return kindList
} }
fun toSearchBook(): SearchBook {
return SearchBook(
name = name,
author = author,
kind = kind,
bookUrl = bookUrl,
origin = origin,
originName = originName,
wordCount = wordCount,
latestChapterTitle = latestChapterTitle,
coverUrl = coverUrl,
intro = intro,
tocUrl = tocUrl
)
}
} }

@ -57,18 +57,18 @@ data class SearchBook(
} }
fun toBook(): Book { fun toBook(): Book {
val book = Book() return Book(
book.name = name name = name,
book.author = author author = author,
book.kind = kind kind = kind,
book.bookUrl = bookUrl bookUrl = bookUrl,
book.origin = origin origin = origin,
book.originName = originName originName = originName,
book.wordCount = wordCount wordCount = wordCount,
book.latestChapterTitle = latestChapterTitle latestChapterTitle = latestChapterTitle,
book.coverUrl = coverUrl coverUrl = coverUrl,
book.intro = intro intro = intro,
book.tocUrl = tocUrl tocUrl = tocUrl
return book )
} }
} }

@ -67,7 +67,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
.onSuccess(Dispatchers.IO) { .onSuccess(Dispatchers.IO) {
it?.let { it?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
book.latestChapterTitle = it.last().title
searchBooks.add(book.toSearchBook())
} }
} }
}.onError { }.onError {

Loading…
Cancel
Save