From 729979f76374a4ac9523c5a0146414704aa5c92a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 19:19:19 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/ui/readbook/ReadBookActivity.kt | 6 +++--- .../java/io/legado/app/ui/readbook/ReadBookViewModel.kt | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) 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) {