wurensen / gradle_plugin_android_aspectjx

A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
Apache License 2.0
365 stars 51 forks source link

[Error] 编译正常,AOP拦截在部分情况下不生效 #70

Open houzixiashanxiedaima opened 1 year ago

houzixiashanxiedaima commented 1 year ago

请提供构建环境相关信息:

onClick的AOP拦截在一些情况下不生效

使用方式:

 @Pointcut("execution(* android.view.View.OnClickListener.onClick(..))")
    fun onClickPointcut() {
    }

 @Throws(Throwable::class)
    @Around("onClickPointcut()")
    fun onClick(joinPoint: ProceedingJoinPoint) {
        val view = joinPoint.args[0] as View
}

生效情况1:

 btn.setOnClickListener(object :OnClickListener{
                override fun onClick(v: View?) {

                }
            })

生效情况2:

 Activity 实现onClick接口
 btn.setOnClickListener(this)

不生效的情况:

 btn.setOnClickListener{
}
wurensen commented 1 year ago

43