diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index fb3027435..08a7eb13c 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -89,4 +89,20 @@ data class Book( } 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 + ) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 45e905847..40b0b6317 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -57,18 +57,18 @@ data class SearchBook( } fun toBook(): Book { - val book = Book() - book.name = name - book.author = author - book.kind = kind - book.bookUrl = bookUrl - book.origin = origin - book.originName = originName - book.wordCount = wordCount - book.latestChapterTitle = latestChapterTitle - book.coverUrl = coverUrl - book.intro = intro - book.tocUrl = tocUrl - return book + return Book( + name = name, + author = author, + kind = kind, + bookUrl = bookUrl, + origin = origin, + originName = originName, + wordCount = wordCount, + latestChapterTitle = latestChapterTitle, + coverUrl = coverUrl, + intro = intro, + tocUrl = tocUrl + ) } } \ No newline at end of file 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 49d602256..f190fe973 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 @@ -67,7 +67,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio .onSuccess(Dispatchers.IO) { it?.let { if (it.isNotEmpty()) { - + book.latestChapterTitle = it.last().title + searchBooks.add(book.toSearchBook()) } } }.onError {