guide 点击事件处理
This commit is contained in:
parent
109b01d9c6
commit
21ace7f399
|
|
@ -438,7 +438,9 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
HighlightPro.with(this@TasksFragment)
|
HighlightPro.with(this@TasksFragment)
|
||||||
.setHighlightParameter {
|
.setHighlightParameter {
|
||||||
HighlightParameter.Builder()
|
HighlightParameter.Builder()
|
||||||
.setHighlightView(binding!!.goldContainer)
|
.setHighlightView(binding!!.goldContainer, {
|
||||||
|
val temp = 111
|
||||||
|
})
|
||||||
.setTipsViewId(R.layout.guide_step_gold)
|
.setTipsViewId(R.layout.guide_step_gold)
|
||||||
.setHighlightShape(RectShape(10.dp, 10.dp, 10.dp))
|
.setHighlightShape(RectShape(10.dp, 10.dp, 10.dp))
|
||||||
.setHighlightHorizontalPadding(0.dp)
|
.setHighlightHorizontalPadding(0.dp)
|
||||||
|
|
@ -448,7 +450,9 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
.setHighlightParameter {
|
.setHighlightParameter {
|
||||||
HighlightParameter.Builder()
|
HighlightParameter.Builder()
|
||||||
.setHighlightView(binding!!.cashContainer)
|
.setHighlightView(binding!!.cashContainer, {
|
||||||
|
val temp = 111
|
||||||
|
})
|
||||||
.setTipsViewId(R.layout.guide_step_cash)
|
.setTipsViewId(R.layout.guide_step_cash)
|
||||||
.setHighlightShape(RectShape(10.dp, 10.dp, 10.dp))
|
.setHighlightShape(RectShape(10.dp, 10.dp, 10.dp))
|
||||||
.setHighlightHorizontalPadding(0.dp)
|
.setHighlightHorizontalPadding(0.dp)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.ama.core.architecture.highlightpro
|
package com.ama.core.architecture.highlightpro
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.graphics.RectF
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.doOnPreDraw
|
import androidx.core.view.doOnPreDraw
|
||||||
|
|
@ -64,14 +67,37 @@ internal class HighlightProImpl : HighlightViewInteractiveAction {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun show() {
|
override fun show() {
|
||||||
if (released) return
|
if (released) return
|
||||||
println("$TAG show")
|
println("$TAG show")
|
||||||
//todo give user access to intercept click event
|
//todo give user access to intercept click event
|
||||||
// if (!intercept) {
|
// if (!intercept) {
|
||||||
maskContainer.setOnClickListener(onClickListener)
|
//maskContainer.setOnClickListener(onClickListener)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
maskContainer.setOnTouchListener { v, event ->
|
||||||
|
when (event?.action) {
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
val highlightRect: RectF? = maskContainer.highLightViewParameters[0].rect
|
||||||
|
highlightRect?.let {
|
||||||
|
if (it.contains(event.x, event.y)) {
|
||||||
|
showNextHighLightView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MotionEvent.ACTION_UP -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
//if constructor's param is activity or view we care about rootView's attachedToWindow
|
//if constructor's param is activity or view we care about rootView's attachedToWindow
|
||||||
//if constructor's param is fragment we care about [fragmentRootView]'s width is not 0
|
//if constructor's param is fragment we care about [fragmentRootView]'s width is not 0
|
||||||
if ((isFragmentRoot.not() && rootView.isAttachToWindow()) ||
|
if ((isFragmentRoot.not() && rootView.isAttachToWindow()) ||
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,11 @@ class HighlightParameter {
|
||||||
* [highLightView] is the view which you want to make it highLight
|
* [highLightView] is the view which you want to make it highLight
|
||||||
* And it will make [setHighlightViewId] useless.
|
* And it will make [setHighlightViewId] useless.
|
||||||
*/
|
*/
|
||||||
fun setHighlightView(highLightView: View): Builder {
|
fun setHighlightView(highLightView: View, onHighViewClicked: ()->Unit): Builder {
|
||||||
highlightParameter.highLightView = highLightView
|
highlightParameter.highLightView = highLightView
|
||||||
|
highlightParameter.highLightView?.setOnClickListener {
|
||||||
|
onHighViewClicked.invoke()
|
||||||
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ open class HighlightShape(val blurRadius: Float = 0.0f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected var rect: RectF? = null
|
var rect: RectF? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init rect child should override initRect and init path
|
* init rect child should override initRect and init path
|
||||||
|
|
@ -33,6 +33,8 @@ open class HighlightShape(val blurRadius: Float = 0.0f) {
|
||||||
this.rect = rectF
|
this.rect = rectF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* draw our path
|
* draw our path
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ internal class MaskContainer constructor(context: Context, attributeSet: Attribu
|
||||||
private var rootWidth: Int = 0
|
private var rootWidth: Int = 0
|
||||||
private var rootHeight: Int = 0
|
private var rootHeight: Int = 0
|
||||||
private var bgColor: Int = -1
|
private var bgColor: Int = -1
|
||||||
private val highLightViewParameters = mutableListOf<HighlightParameter>()
|
val highLightViewParameters = mutableListOf<HighlightParameter>()
|
||||||
private val defaultHighlightBgColor: Int
|
private val defaultHighlightBgColor: Int
|
||||||
get() = "#80000000".toColorInt()
|
get() = "#80000000".toColorInt()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue