优化
This commit is contained in:
@@ -134,7 +134,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
val textActionMenu: TextActionMenu by lazy {
|
val textActionMenu: TextActionMenu by lazy {
|
||||||
TextActionMenu(this, this)
|
TextActionMenu(this, this)
|
||||||
}
|
}
|
||||||
private val popupAction by lazy {
|
override val imagePopupAction: PopupAction by lazy {
|
||||||
PopupAction(this)
|
PopupAction(this)
|
||||||
}
|
}
|
||||||
override val isInitFinish: Boolean get() = viewModel.isInitFinish
|
override val isInitFinish: Boolean get() = viewModel.isInitFinish
|
||||||
@@ -960,26 +960,26 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
* 长按图片
|
* 长按图片
|
||||||
*/
|
*/
|
||||||
override fun onImageLongPress(x: Float, y: Float, src: String) {
|
override fun onImageLongPress(x: Float, y: Float, src: String) {
|
||||||
popupAction.setItems(
|
imagePopupAction.setItems(
|
||||||
listOf(
|
listOf(
|
||||||
SelectItem("查看", "show"),
|
SelectItem("查看", "show"),
|
||||||
SelectItem("刷新", "refresh")
|
SelectItem("刷新", "refresh")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
popupAction.onActionClick = {
|
imagePopupAction.onActionClick = {
|
||||||
when (it) {
|
when (it) {
|
||||||
"show" -> showDialogFragment(PhotoDialog(src))
|
"show" -> showDialogFragment(PhotoDialog(src))
|
||||||
"refresh" -> {
|
"refresh" -> {
|
||||||
ImageProvider.bitmapLruCache.remove(src)
|
ImageProvider.bitmapLruCache.remove(src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
popupAction.dismiss()
|
imagePopupAction.dismiss()
|
||||||
}
|
}
|
||||||
val navigationBarHeight =
|
val navigationBarHeight =
|
||||||
if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM)
|
if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM)
|
||||||
navigationBarHeight else 0
|
navigationBarHeight else 0
|
||||||
popupAction.showAtLocation(
|
imagePopupAction.showAtLocation(
|
||||||
binding.readView, Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, x.toInt(),
|
binding.readView, Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0,
|
||||||
binding.root.height + navigationBarHeight - y.toInt()
|
binding.root.height + navigationBarHeight - y.toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1102,7 +1102,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
textActionMenu.dismiss()
|
textActionMenu.dismiss()
|
||||||
popupAction.dismiss()
|
imagePopupAction.dismiss()
|
||||||
binding.readView.onDestroy()
|
binding.readView.onDestroy()
|
||||||
ReadBook.msg = null
|
ReadBook.msg = null
|
||||||
ReadBook.callBack = null
|
ReadBook.callBack = null
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter
|
|||||||
import io.legado.app.ui.book.read.page.entities.TextPos
|
import io.legado.app.ui.book.read.page.entities.TextPos
|
||||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||||
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
||||||
|
import io.legado.app.ui.widget.PopupAction
|
||||||
import io.legado.app.utils.activity
|
import io.legado.app.utils.activity
|
||||||
import io.legado.app.utils.screenshot
|
import io.legado.app.utils.screenshot
|
||||||
import java.text.BreakIterator
|
import java.text.BreakIterator
|
||||||
@@ -206,6 +207,10 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
|||||||
if (!pressDown) return true
|
if (!pressDown) return true
|
||||||
pressDown = false
|
pressDown = false
|
||||||
if (!isMove) {
|
if (!isMove) {
|
||||||
|
if (!longPressed && callBack.imagePopupAction.isShowing) {
|
||||||
|
callBack.imagePopupAction.dismiss()
|
||||||
|
return true
|
||||||
|
}
|
||||||
if (!longPressed && !pressOnTextSelected) {
|
if (!longPressed && !pressOnTextSelected) {
|
||||||
onSingleTapUp()
|
onSingleTapUp()
|
||||||
return true
|
return true
|
||||||
@@ -539,6 +544,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
|||||||
val isInitFinish: Boolean
|
val isInitFinish: Boolean
|
||||||
val isAutoPage: Boolean
|
val isAutoPage: Boolean
|
||||||
val autoPageProgress: Int
|
val autoPageProgress: Int
|
||||||
|
val imagePopupAction: PopupAction
|
||||||
fun showActionMenu()
|
fun showActionMenu()
|
||||||
fun screenOffTimerStart()
|
fun screenOffTimerStart()
|
||||||
fun showTextActionMenu()
|
fun showTextActionMenu()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class PopupAction(private val context: Context) :
|
|||||||
contentView = binding.root
|
contentView = binding.root
|
||||||
|
|
||||||
isTouchable = true
|
isTouchable = true
|
||||||
isOutsideTouchable = true
|
isOutsideTouchable = false
|
||||||
isFocusable = false
|
isFocusable = false
|
||||||
|
|
||||||
binding.recyclerView.adapter = adapter
|
binding.recyclerView.adapter = adapter
|
||||||
|
|||||||
Reference in New Issue
Block a user