换源不在改变书名和作者

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

Loading…
Cancel
Save