优化
This commit is contained in:
@@ -323,6 +323,21 @@ data class Book(
|
|||||||
return newBook
|
return newBook
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateTo(newBook: Book): Book {
|
||||||
|
newBook.durChapterIndex = durChapterIndex
|
||||||
|
newBook.durChapterTitle = durChapterTitle
|
||||||
|
newBook.durChapterPos = durChapterPos
|
||||||
|
newBook.durChapterTime = durChapterTime
|
||||||
|
newBook.group = group
|
||||||
|
newBook.order = order
|
||||||
|
newBook.customCoverUrl = customCoverUrl
|
||||||
|
newBook.customIntro = customIntro
|
||||||
|
newBook.customTag = customTag
|
||||||
|
newBook.canUpdate = canUpdate
|
||||||
|
newBook.readConfig = readConfig
|
||||||
|
return newBook
|
||||||
|
}
|
||||||
|
|
||||||
fun createBookMark(): Bookmark {
|
fun createBookMark(): Bookmark {
|
||||||
return Bookmark(
|
return Bookmark(
|
||||||
bookName = name,
|
bookName = name,
|
||||||
|
|||||||
@@ -18,7 +18,13 @@ import io.legado.app.data.entities.BookSource
|
|||||||
import io.legado.app.exception.NoBooksDirException
|
import io.legado.app.exception.NoBooksDirException
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.AppWebDav
|
import io.legado.app.help.AppWebDav
|
||||||
import io.legado.app.help.book.*
|
import io.legado.app.help.book.BookHelp
|
||||||
|
import io.legado.app.help.book.getExportFileName
|
||||||
|
import io.legado.app.help.book.getRemoteUrl
|
||||||
|
import io.legado.app.help.book.isLocal
|
||||||
|
import io.legado.app.help.book.isSameNameAuthor
|
||||||
|
import io.legado.app.help.book.isWebFile
|
||||||
|
import io.legado.app.help.book.removeType
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.lib.webdav.ObjectNotFoundException
|
import io.legado.app.lib.webdav.ObjectNotFoundException
|
||||||
import io.legado.app.model.BookCover
|
import io.legado.app.model.BookCover
|
||||||
@@ -26,7 +32,11 @@ import io.legado.app.model.ReadBook
|
|||||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||||
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.model.webBook.WebBook
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.ArchiveUtils
|
||||||
|
import io.legado.app.utils.UrlUtil
|
||||||
|
import io.legado.app.utils.isContentScheme
|
||||||
|
import io.legado.app.utils.postEvent
|
||||||
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
|
||||||
@@ -157,17 +167,18 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
loadChapter(book, scope)
|
loadChapter(book, scope)
|
||||||
} else {
|
} else {
|
||||||
bookSource?.let { bookSource ->
|
bookSource?.let { bookSource ->
|
||||||
val oldBook = book.copy()
|
|
||||||
WebBook.getBookInfo(this, bookSource, book, canReName = canReName)
|
WebBook.getBookInfo(this, bookSource, book, canReName = canReName)
|
||||||
.onSuccess(IO) {
|
.onSuccess(IO) {
|
||||||
appDb.bookDao.getBook(book.name, book.author)?.let {
|
val dbBook = appDb.bookDao.getBook(book.name, book.author)
|
||||||
|
if (dbBook != null) {
|
||||||
|
dbBook.updateTo(it)
|
||||||
inBookshelf = true
|
inBookshelf = true
|
||||||
}
|
}
|
||||||
bookData.postValue(it)
|
bookData.postValue(it)
|
||||||
if (inBookshelf) {
|
if (inBookshelf) {
|
||||||
appDb.bookDao.update(it)
|
appDb.bookDao.update(it)
|
||||||
if (oldBook.name != book.name) {
|
if (dbBook!!.name != book.name) {
|
||||||
BookHelp.updateCacheFolder(oldBook, book)
|
BookHelp.updateCacheFolder(dbBook, book)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (it.isWebFile) {
|
if (it.isWebFile) {
|
||||||
|
|||||||
Reference in New Issue
Block a user