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() invalidate()
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { fun upVisibleRect() {
super.onSizeChanged(w, h, oldw, oldh)
ChapterProvider.viewWidth = w
ChapterProvider.viewHeight = h
ChapterProvider.upSize()
visibleRect.set( visibleRect.set(
ChapterProvider.paddingLeft.toFloat(), ChapterProvider.paddingLeft.toFloat(),
ChapterProvider.paddingTop.toFloat(), ChapterProvider.paddingTop.toFloat(),
ChapterProvider.visibleRight.toFloat(), ChapterProvider.visibleRight.toFloat(),
ChapterProvider.visibleBottom.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() textPage.format()
} }

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

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

Loading…
Cancel
Save