pull/51/head
kunfei 5 years ago
parent eaedae175b
commit 4a208b4729
  1. 10
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 11
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.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()

@ -243,15 +243,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(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<ReadBookViewModel>(R.layout.activity_boo
page_view.upBg()
page_view.upStyle()
if (it) {
loadContent()
ReadBook.loadContent()
} else {
page_view.upContent()
}

@ -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)?) {

Loading…
Cancel
Save