txt目录改变时正文内容没有及时刷新

pull/1592/head
Xwite 3 years ago
parent 3f723c88d3
commit fdfa9a3ff2
  1. 3
      app/src/main/java/io/legado/app/model/ReadBook.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -31,6 +31,7 @@ object ReadBook : CoroutineScope by MainScope() {
var book: Book? = null
var callBack: CallBack? = null
var inBookshelf = false
var tocChanged = false
var chapterSize = 0
var durChapterIndex = 0
var durChapterPos = 0
@ -65,7 +66,7 @@ object ReadBook : CoroutineScope by MainScope() {
fun upData(book: Book) {
ReadBook.book = book
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
if (durChapterIndex != book.durChapterIndex) {
if (durChapterIndex != book.durChapterIndex || tocChanged) {
durChapterIndex = book.durChapterIndex
durChapterPos = book.durChapterPos
clearTextChapter()

@ -91,6 +91,7 @@ class BookInfoActivity :
viewModel.upEditBook()
}
}
private var tocChanged = false
override val binding by viewBinding(ActivityBookInfoBinding::inflate)
override val viewModel by viewModels<BookInfoViewModel>()
@ -189,6 +190,7 @@ class BookInfoActivity :
R.id.menu_log -> showDialogFragment<AppLogDialog>()
R.id.menu_limit_content_length -> {
upLoading(true)
tocChanged = true
viewModel.bookData.value?.let {
it.setLimitContentLength(!item.isChecked)
viewModel.loadBookInfo(it, false)
@ -441,8 +443,10 @@ class BookInfoActivity :
Intent(this, ReadBookActivity::class.java)
.putExtra("bookUrl", book.bookUrl)
.putExtra("inBookshelf", viewModel.inBookshelf)
.putExtra("tocChanged", tocChanged)
)
}
tocChanged = false
}
override val oldBook: Book?

@ -40,6 +40,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) {
execute {
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
ReadBook.tocChanged = intent.getBooleanExtra("tocChanged", false)
val bookUrl = intent.getStringExtra("bookUrl")
val book = when {
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook

Loading…
Cancel
Save