feat: 优化代码

pull/117/head
kunfei 5 years ago
parent aafa690692
commit ee1f04f42c
  1. 9
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt

@ -15,7 +15,6 @@ import java.util.*
class ContentView(context: Context) : FrameLayout(context) { class ContentView(context: Context) : FrameLayout(context) {
private var pageSize: Int = 0
init { init {
//设置背景防止切换背景时文字重叠 //设置背景防止切换背景时文字重叠
@ -26,8 +25,7 @@ class ContentView(context: Context) : FrameLayout(context) {
upTime() upTime()
content_text_view.upView = { content_text_view.upView = {
tv_bottom_left.text = it.title tv_bottom_left.text = it.title
pageSize = it.pageSize setPageIndex(it.index, it.pageSize)
setPageIndex(it.index)
} }
} }
@ -97,8 +95,7 @@ class ContentView(context: Context) : FrameLayout(context) {
fun setContent(textPage: TextPage) { fun setContent(textPage: TextPage) {
tv_bottom_left.text = textPage.title tv_bottom_left.text = textPage.title
pageSize = textPage.pageSize setPageIndex(textPage.index, textPage.pageSize)
setPageIndex(textPage.index)
content_text_view.resetPageOffset() content_text_view.resetPageOffset()
content_text_view.setContent(textPage) content_text_view.setContent(textPage)
} }
@ -108,7 +105,7 @@ class ContentView(context: Context) : FrameLayout(context) {
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun setPageIndex(pageIndex: Int?) { fun setPageIndex(pageIndex: Int?, pageSize: Int) {
pageIndex?.let { pageIndex?.let {
tv_bottom_right.text = "${pageIndex.plus(1)}/${pageSize}" tv_bottom_right.text = "${pageIndex.plus(1)}/${pageSize}"
} }

Loading…
Cancel
Save