Skip to content

Commit

Permalink
feat: src点击回调增加位置信息
Browse files Browse the repository at this point in the history
  • Loading branch information
hexleo committed Aug 3, 2022
1 parent 55f37f1 commit c4531a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class MixTouch(private val mixAnimPlugin: MixAnimPlugin) {
list?.forEach {frame ->
val src = mixAnimPlugin.srcMap?.map?.get(frame.srcId) ?: return@forEach
if (calClick(x.toInt(), y.toInt(), frame.frame)) {
return Resource(src)
return Resource(src).apply {
curPoint = frame.frame
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
package com.tencent.qgame.animplayer.mix

import android.graphics.Bitmap
import com.tencent.qgame.animplayer.PointRect

/**
* 资源描述
*/
class Resource {
class Resource(src: Src) {
var id = ""
var type = Src.SrcType.UNKNOWN
var loadType = Src.LoadType.UNKNOWN
var tag = ""
var bitmap: Bitmap? = null
var curPoint: PointRect? = null // src在当前帧的位置信息

constructor(src: Src) {
init {
id = src.srcId
type = src.srcType
loadType = src.loadType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class AnimVapxDemoActivity : Activity(), IAnimListener {
Handler(Looper.getMainLooper())
}

private var lastToast: Toast? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_anim_simple_demo)
Expand Down Expand Up @@ -140,11 +142,13 @@ class AnimVapxDemoActivity : Activity(), IAnimListener {
// 注册点击事件监听
animView.setOnResourceClickListener(object : OnResourceClickListener {
override fun onClick(resource: Resource) {
Toast.makeText(
lastToast?.cancel()
lastToast = Toast.makeText(
this@AnimVapxDemoActivity,
"srcTag=${resource.tag} onClick",
"srcTag=${resource.tag} onClick ${resource.curPoint}",
Toast.LENGTH_LONG
).show()
)
lastToast?.show()
}
})

Expand Down

0 comments on commit c4531a9

Please sign in to comment.