feat: 优化代码

pull/111/head
kunfei 5 years ago
parent 57a472b411
commit d0dd584893
  1. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt

@ -344,13 +344,13 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun upSelectedStart(x: Float, y: Float) { override fun upSelectedStart(x: Float, y: Float) {
cursor_left.x = x - cursor_left.width cursor_left.x = x - cursor_left.width
cursor_left.y = y cursor_left.y = y
cursor_left.visible() cursor_left.visible(true)
} }
override fun upSelectedEnd(x: Float, y: Float) { override fun upSelectedEnd(x: Float, y: Float) {
cursor_right.x = x cursor_right.x = x
cursor_right.y = y cursor_right.y = y
cursor_right.visible() cursor_right.visible(true)
} }
override fun onCancelSelect() { override fun onCancelSelect() {

@ -50,10 +50,10 @@ fun View.visible() {
} }
fun View.visible(visible: Boolean) { fun View.visible(visible: Boolean) {
visibility = if (visible) { if (visible && visibility != VISIBLE) {
VISIBLE visibility = VISIBLE
} else { } else if (!visible && visibility == VISIBLE) {
INVISIBLE visibility = INVISIBLE
} }
} }

Loading…
Cancel
Save