feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 702b0d0022
commit 7af2b7ade0
  1. 16
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -7,6 +7,7 @@ import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.view.* import android.view.*
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.appcompat.view.menu.MenuItemImpl import androidx.appcompat.view.menu.MenuItemImpl
import androidx.core.view.get import androidx.core.view.get
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -379,20 +380,13 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
textActionMenu ?: let { textActionMenu ?: let {
textActionMenu = TextActionMenu(this, this) textActionMenu = TextActionMenu(this, this)
} }
val x = cursor_left.x.toInt() + cursor_left.width
val y = (page_view.height - cursor_left.y + ReadBookConfig.textSize.dp * 1.5).toInt()
textActionMenu?.let { popup -> textActionMenu?.let { popup ->
if (!popup.isShowing) { if (!popup.isShowing) {
popup.showAtLocation( popup.showAtLocation(cursor_left, Gravity.BOTTOM or Gravity.START, x, y)
cursor_left,
Gravity.BOTTOM or Gravity.START,
cursor_left.x.toInt() + cursor_left.width,
page_view.height - cursor_left.y.toInt() + ReadBookConfig.textSize.dp + popup.height
)
} else { } else {
popup.update( popup.update(x, y, WRAP_CONTENT, WRAP_CONTENT)
cursor_left.x.toInt() + cursor_left.width,
page_view.height - cursor_left.y.toInt() + ReadBookConfig.textSize.dp + popup.height,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT
)
} }
} }
} }

Loading…
Cancel
Save