This commit is contained in:
kunfei
2022-02-27 18:59:42 +08:00
parent fd2200ac06
commit 719be50ed5
14 changed files with 32 additions and 7 deletions
@@ -6,6 +6,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.TocRule
import io.legado.app.help.ContentProcessor
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.TocEmptyException
@@ -118,9 +119,10 @@ object BookChapterList {
list.forEachIndexed { index, bookChapter ->
bookChapter.index = index
}
book.latestChapterTitle = list.last().title
book.durChapterTitle =
list.getOrNull(book.durChapterIndex)?.title ?: book.latestChapterTitle
val replaceRules = ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
book.latestChapterTitle = list.last().getDisplayTitle(replaceRules)
book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
.getDisplayTitle(replaceRules)
if (book.totalChapterNum < list.size) {
book.lastCheckCount = list.size - book.totalChapterNum
book.latestChapterTime = System.currentTimeMillis()
@@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.model.AudioPlay
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.postEvent
@@ -120,7 +121,9 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
chapters,
oldTocSize
)
book.durChapterTitle = chapters[book.durChapterIndex].title
book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
appDb.bookDao.update(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray())
}
@@ -13,6 +13,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.ReadBook
@@ -208,7 +209,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
chapters,
oldTocSize
)
book.durChapterTitle = chapters[book.durChapterIndex].title
book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
if (inBookshelf) {
appDb.bookDao.update(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray())
@@ -19,6 +19,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.ReadBook
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.applyTint
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO
@@ -78,6 +79,8 @@ class ContentEditDialog : BaseDialogFragment(R.layout.dialog_content_edit) {
binding.contentView.setText(content)
ReadBook.loadContent(ReadBook.durChapterIndex, resetPageOffset = false)
}
R.id.menu_copy_all -> requireContext()
.sendToClip("${binding.toolBar.title}\n${viewModel.content}")
}
return@setOnMenuItemClickListener true
}
@@ -189,7 +189,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
chapters,
oldBook.totalChapterNum
)
book.durChapterTitle = chapters[book.durChapterIndex].title
book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
oldBook.changeTo(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray())
ReadBook.resetData(book)