diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 11b411413..1a7aae0a8 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -180,7 +180,13 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } changeSourceDialog?.show(supportFragmentManager, ChangeSourceDialog.tag) } - R.id.menu_refresh -> viewModel.refreshContent() + R.id.menu_refresh -> { + viewModel.bookData.value?.let { + viewModel.curTextChapter = null + page_view.upContent() + viewModel.refreshContent(it) + } + } } return super.onCompatOptionsItemSelected(item) } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index fb64672df..767bd0849 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -214,6 +214,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { durChapterIndex++ prevTextChapter = curTextChapter curTextChapter = nextTextChapter + nextTextChapter = null bookData.value?.let { loadContent(it, durChapterIndex.plus(1)) } @@ -223,18 +224,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { durChapterIndex-- nextTextChapter = curTextChapter curTextChapter = prevTextChapter + prevTextChapter = null bookData.value?.let { loadContent(it, durChapterIndex.minus(1)) } } - fun refreshContent() { + fun refreshContent(book: Book) { execute { - bookData.value?.let { book -> - App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> - BookHelp.delContent(book, chapter) - loadContent(book, durChapterIndex) - } + App.db.bookChapterDao().getChapter(book.bookUrl, durChapterIndex)?.let { chapter -> + BookHelp.delContent(book, chapter) + loadContent(book, durChapterIndex) } } }