换源不在改变书名和作者

pull/348/head
gedoor 4 years ago
parent 6ea1cba8c0
commit 5890237121
  1. 10
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -9,8 +9,8 @@ import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp
import io.legado.app.model.webBook.WebBook
import io.legado.app.model.localBook.LocalBook
import io.legado.app.model.webBook.WebBook
import io.legado.app.service.help.ReadBook
import kotlinx.coroutines.Dispatchers.IO
@ -49,15 +49,15 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
}
fun loadBookInfo(
book: Book,
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null
book: Book, canReName: Boolean = true,
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null,
) {
execute {
if (book.isLocalBook()) {
loadChapter(book, changeDruChapterIndex)
} else {
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource ->
WebBook(bookSource).getBookInfo(book, this)
WebBook(bookSource).getBookInfo(book, this, canReName = canReName)
.onSuccess(IO) {
bookData.postValue(book)
if (inBookshelf) {
@ -138,7 +138,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
}
bookData.postValue(newBook)
if (newBook.tocUrl.isEmpty()) {
loadBookInfo(newBook) { upChangeDurChapterIndex(newBook, it) }
loadBookInfo(newBook, false) { upChangeDurChapterIndex(newBook, it) }
} else {
loadChapter(newBook) { upChangeDurChapterIndex(newBook, it) }
}

Loading…
Cancel
Save