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 cea8c77d1..724d7b2c7 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 @@ -236,9 +236,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea private fun bookLoadFinish() { viewModel.bookData.value?.let { - viewModel.loadContent(it, it.durChapterIndex) - viewModel.loadContent(it, it.durChapterIndex + 1) - viewModel.loadContent(it, it.durChapterIndex - 1) + viewModel.loadContent(it, viewModel.durChapterIndex) + viewModel.loadContent(it, viewModel.durChapterIndex + 1) + viewModel.loadContent(it, viewModel.durChapterIndex - 1) } } 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 4184ee895..5fad1c557 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 @@ -59,6 +59,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { toast(R.string.error_load_toc) } ?: autoChangeSource() } else { + if (durChapterIndex > count - 1) { + durChapterIndex = count - 1 + } chapterMaxIndex.postValue(count) } } @@ -81,6 +84,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { loadingChapters.remove(index) } } ?: download(book, chapter) + } ?: synchronized(loadingLock) { + loadingChapters.remove(index) } }.onError { synchronized(loadingLock) {