mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
txt目录改变时正文内容没有及时刷新
This commit is contained in:
parent
3f723c88d3
commit
fdfa9a3ff2
@ -31,6 +31,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
var book: Book? = null
|
var book: Book? = null
|
||||||
var callBack: CallBack? = null
|
var callBack: CallBack? = null
|
||||||
var inBookshelf = false
|
var inBookshelf = false
|
||||||
|
var tocChanged = false
|
||||||
var chapterSize = 0
|
var chapterSize = 0
|
||||||
var durChapterIndex = 0
|
var durChapterIndex = 0
|
||||||
var durChapterPos = 0
|
var durChapterPos = 0
|
||||||
@ -65,7 +66,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
fun upData(book: Book) {
|
fun upData(book: Book) {
|
||||||
ReadBook.book = book
|
ReadBook.book = book
|
||||||
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
|
||||||
if (durChapterIndex != book.durChapterIndex) {
|
if (durChapterIndex != book.durChapterIndex || tocChanged) {
|
||||||
durChapterIndex = book.durChapterIndex
|
durChapterIndex = book.durChapterIndex
|
||||||
durChapterPos = book.durChapterPos
|
durChapterPos = book.durChapterPos
|
||||||
clearTextChapter()
|
clearTextChapter()
|
||||||
|
@ -91,6 +91,7 @@ class BookInfoActivity :
|
|||||||
viewModel.upEditBook()
|
viewModel.upEditBook()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private var tocChanged = false
|
||||||
|
|
||||||
override val binding by viewBinding(ActivityBookInfoBinding::inflate)
|
override val binding by viewBinding(ActivityBookInfoBinding::inflate)
|
||||||
override val viewModel by viewModels<BookInfoViewModel>()
|
override val viewModel by viewModels<BookInfoViewModel>()
|
||||||
@ -189,6 +190,7 @@ class BookInfoActivity :
|
|||||||
R.id.menu_log -> showDialogFragment<AppLogDialog>()
|
R.id.menu_log -> showDialogFragment<AppLogDialog>()
|
||||||
R.id.menu_limit_content_length -> {
|
R.id.menu_limit_content_length -> {
|
||||||
upLoading(true)
|
upLoading(true)
|
||||||
|
tocChanged = true
|
||||||
viewModel.bookData.value?.let {
|
viewModel.bookData.value?.let {
|
||||||
it.setLimitContentLength(!item.isChecked)
|
it.setLimitContentLength(!item.isChecked)
|
||||||
viewModel.loadBookInfo(it, false)
|
viewModel.loadBookInfo(it, false)
|
||||||
@ -441,8 +443,10 @@ class BookInfoActivity :
|
|||||||
Intent(this, ReadBookActivity::class.java)
|
Intent(this, ReadBookActivity::class.java)
|
||||||
.putExtra("bookUrl", book.bookUrl)
|
.putExtra("bookUrl", book.bookUrl)
|
||||||
.putExtra("inBookshelf", viewModel.inBookshelf)
|
.putExtra("inBookshelf", viewModel.inBookshelf)
|
||||||
|
.putExtra("tocChanged", tocChanged)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
tocChanged = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override val oldBook: Book?
|
override val oldBook: Book?
|
||||||
|
@ -40,6 +40,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
fun initData(intent: Intent) {
|
fun initData(intent: Intent) {
|
||||||
execute {
|
execute {
|
||||||
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
||||||
|
ReadBook.tocChanged = intent.getBooleanExtra("tocChanged", false)
|
||||||
val bookUrl = intent.getStringExtra("bookUrl")
|
val bookUrl = intent.getStringExtra("bookUrl")
|
||||||
val book = when {
|
val book = when {
|
||||||
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
|
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
|
||||||
|
Loading…
Reference in New Issue
Block a user