Merge remote-tracking branch 'upstream/master'

pull/1155/head
github-actions 4 years ago
commit 5640e9641a
  1. 9
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -27,7 +27,6 @@ import kotlin.math.min
object ReadBook {
var titleDate = MutableLiveData<String>()
var book: Book? = null
var contentProcessor: ContentProcessor? = null
var inBookshelf = false
var chapterSize = 0
var durChapterIndex = 0
@ -46,7 +45,6 @@ object ReadBook {
fun resetData(book: Book) {
this.book = book
contentProcessor = ContentProcessor.get(book.name, book.origin)
readRecord.bookName = book.name
readRecord.readTime = appDb.readRecordDao.getReadTime(book.name) ?: 0
durChapterIndex = book.durChapterIndex
@ -414,9 +412,10 @@ object ReadBook {
2 -> ChineseUtils.s2t(chapter.title)
else -> chapter.title
}
val contents = contentProcessor!!.getContent(book, chapter.title, content)
val textChapter =
ChapterProvider.getTextChapter(book, chapter, contents, chapterSize)
val contents = ContentProcessor.get(book.name, book.origin)
.getContent(book, chapter.title, content)
val textChapter = ChapterProvider
.getTextChapter(book, chapter, contents, chapterSize)
val offset = chapter.index - durChapterIndex
if (upContent) callBack?.upContent(offset, resetPageOffset)

@ -11,6 +11,7 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookProgress
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.help.storage.BookWebDav
import io.legado.app.model.localBook.LocalBook
import io.legado.app.model.webBook.PreciseSearch
@ -302,8 +303,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
*/
fun replaceRuleChanged() {
execute {
ReadBook.contentProcessor?.upReplaceRules()
ReadBook.loadContent(resetPageOffset = false)
ReadBook.book?.let {
ContentProcessor.get(it.name, it.origin).upReplaceRules()
ReadBook.loadContent(resetPageOffset = false)
}
}
}

Loading…
Cancel
Save