feat: 优化代码

pull/120/head
kunfei 5 years ago
parent b2d0bd5de2
commit 37bdfee195
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt

@ -47,17 +47,21 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
invalidate()
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
ChapterProvider.viewWidth = w
ChapterProvider.viewHeight = h
ChapterProvider.upSize()
fun upVisibleRect() {
visibleRect.set(
ChapterProvider.paddingLeft.toFloat(),
ChapterProvider.paddingTop.toFloat(),
ChapterProvider.visibleRight.toFloat(),
ChapterProvider.visibleBottom.toFloat()
)
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
ChapterProvider.viewWidth = w
ChapterProvider.viewHeight = h
ChapterProvider.upSize()
upVisibleRect()
textPage.format()
}

@ -52,12 +52,7 @@ class ContentView(context: Context) : FrameLayout(context) {
ll_header.gone()
page_panel.setPadding(0, context.statusBarHeight, 0, 0)
}
content_text_view.setPadding(
paddingLeft.dp,
paddingTop.dp,
paddingRight.dp,
paddingBottom.dp
)
content_text_view.upVisibleRect()
ll_footer.setPadding(
footerPaddingLeft.dp,
footerPaddingTop.dp,

@ -141,6 +141,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
}
}
}
searchBooks = copyDataS
searchBookLiveData.postValue(copyDataS)
}

Loading…
Cancel
Save