diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index cf336f7d0..7603c0ab3 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -169,6 +169,15 @@ object ReadBook { } } + /** + * 加载章节内容 + */ + fun loadContent() { + loadContent(durChapterIndex) + loadContent(durChapterIndex + 1) + loadContent(durChapterIndex - 1) + } + fun loadContent(index: Int) { book?.let { book -> if (addLoading(index)) { @@ -287,7 +296,6 @@ object ReadBook { } interface CallBack { - fun loadContent() fun upContent(position: Int = 0) fun upView() fun upPageProgress() diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index c0720eaef..52ea156b4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -243,15 +243,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo return false } - /** - * 加载章节内容 - */ - override fun loadContent() { - ReadBook.loadContent(ReadBook.durChapterIndex) - ReadBook.loadContent(ReadBook.durChapterIndex + 1) - ReadBook.loadContent(ReadBook.durChapterIndex - 1) - } - /** * 内容加载完成 */ @@ -433,7 +424,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo page_view.upBg() page_view.upStyle() if (it) { - loadContent() + ReadBook.loadContent() } else { page_view.upContent() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 2e6f127dc..66d0a0b71 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -49,7 +49,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.durChapterIndex = count - 1 } ReadBook.chapterSize = count - ReadBook.callBack?.loadContent() + ReadBook.loadContent() } if (ReadBook.inBookshelf) { ReadBook.saveRead() @@ -93,7 +93,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { if (changeDruChapterIndex == null) { App.db.bookChapterDao().insert(*cList.toTypedArray()) ReadBook.chapterSize = cList.size - ReadBook.callBack?.loadContent() + ReadBook.loadContent() } else { changeDruChapterIndex(cList) } @@ -146,7 +146,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { App.db.bookDao().update(book) App.db.bookChapterDao().insert(*chapters.toTypedArray()) ReadBook.chapterSize = chapters.size - ReadBook.callBack?.loadContent() + ReadBook.loadContent() } } @@ -160,7 +160,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.durPageIndex = 0 } ReadBook.saveRead() - ReadBook.callBack?.loadContent() + ReadBook.loadContent() } fun removeFromBookshelf(success: (() -> Unit)?) {