feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 943e5fb76c
commit 56910ffbc3
  1. 5
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  2. 21
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -16,7 +16,6 @@ import java.util.*
class ContentView(context: Context) : FrameLayout(context) {
var callBack: CallBack? = null
private var pageSize: Int = 0
init {
@ -135,8 +134,4 @@ class ContentView(context: Context) : FrameLayout(context) {
val selectedText: String get() = content_text_view.selectedText
interface CallBack {
fun scrollToLine(line: Int)
fun scrollToLast()
}
}

@ -16,7 +16,6 @@ import io.legado.app.utils.getPrefInt
class PageView(context: Context, attrs: AttributeSet) :
FrameLayout(context, attrs),
ContentView.CallBack,
DataSource {
var callBack: CallBack
@ -39,7 +38,6 @@ class PageView(context: Context, attrs: AttributeSet) :
setWillNotDraw(false)
pageFactory = TextPageFactory(this)
upPageAnim(context.getPrefInt(PreferKey.pageAnim))
curPage.callBack = this
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
@ -199,25 +197,6 @@ class PageView(context: Context, attrs: AttributeSet) :
return ReadBook.durChapterIndex > 0
}
override fun scrollToLine(line: Int) {
if (isScrollDelegate) {
ReadBook.textChapter()?.let {
val pageIndex = it.getPageIndex(line)
curPage.setPageIndex(pageIndex)
callBack.setPageIndex(pageIndex)
}
}
}
override fun scrollToLast() {
if (isScrollDelegate) {
ReadBook.textChapter()?.let {
callBack.setPageIndex(it.lastIndex())
curPage.setPageIndex(it.lastIndex())
}
}
}
interface CallBack {
val isInitFinish: Boolean

Loading…
Cancel
Save