update SlidePageDelegate

pull/32/head
Administrator 5 years ago
parent 3f13a65d7f
commit 2949d7200a
  1. 6
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  2. 22
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt

@ -54,7 +54,9 @@ class ContentView : FrameLayout {
} }
fun setContent(text: CharSequence?) { fun setContent(page: TextPage?) {
content_text_view.text = text content_text_view.text = page?.text
//bottom_status_bar draw index
} }
} }

@ -99,26 +99,26 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
when (chapterOnDur) { when (chapterOnDur) {
0 -> { 0 -> {
cb.textChapter()?.let { cb.textChapter()?.let {
curPage?.setContent(it.page(cb.durChapterPos(it.pageSize()))?.text) curPage?.setContent(it.page(cb.durChapterPos(it.pageSize())))
if (cb.durChapterPos(it.pageSize()) > 0) { if (cb.durChapterPos(it.pageSize()) > 0) {
prevPage?.setContent(it.page(cb.durChapterPos(it.pageSize()) - 1)?.text) prevPage?.setContent(it.page(cb.durChapterPos(it.pageSize()) - 1))
} }
if (cb.durChapterPos(it.pageSize()) < it.pageSize() - 1) { if (cb.durChapterPos(it.pageSize()) < it.pageSize() - 1) {
nextPage?.setContent(it.page(cb.durChapterPos(it.pageSize()) + 1)?.text) nextPage?.setContent(it.page(cb.durChapterPos(it.pageSize()) + 1))
} }
} }
} }
1 -> { 1 -> {
cb.textChapter()?.let { cb.textChapter()?.let {
if (cb.durChapterPos(it.pageSize()) == it.pageSize() - 1) { if (cb.durChapterPos(it.pageSize()) == it.pageSize() - 1) {
nextPage?.setContent(cb.textChapter(1)?.page(0)?.text) nextPage?.setContent(cb.textChapter(1)?.page(0))
} }
} }
} }
-1 -> { -1 -> {
cb.textChapter()?.let { cb.textChapter()?.let {
if (cb.durChapterPos(it.pageSize()) == 0) { if (cb.durChapterPos(it.pageSize()) == 0) {
prevPage?.setContent(cb.textChapter(-1)?.lastPage()?.text) prevPage?.setContent(cb.textChapter(-1)?.lastPage())
} }
} }
} }
@ -143,9 +143,9 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
} }
} }
prevPage?.setContent(it.previousPage()?.text) prevPage?.setContent(it.previousPage())
curPage?.setContent(it.currentPage()?.text) curPage?.setContent(it.currentPage())
nextPage?.setContent(it.nextPage()?.text) nextPage?.setContent(it.nextPage())
} }
} }
@ -154,9 +154,9 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
//可做成异步回调 //可做成异步回调
pageFactory?.let { pageFactory?.let {
prevPage?.setContent(it.previousPage()?.text) prevPage?.setContent(it.previousPage())
curPage?.setContent(it.currentPage()?.text) curPage?.setContent(it.currentPage())
nextPage?.setContent(it.nextPage()?.text) nextPage?.setContent(it.nextPage())
} }
} }

Loading…
Cancel
Save