SingleClick:
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotatiapproachonTarget.FUNCTION)
annotation chttp 500lass SingleClick(
//java环境变量装备 点击距离时间,毫秒
vAPPal value: Long = 500
)
SingleClickAspect:
import android.os.SystemClock
import org.aspechttp 500tj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Aandroid下载rounappleidd
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Pointcut
import org.aspectj.lang.reflect.MethodSignature
@Aspect
capplicationlass SingleClickAspect {
/*APP*
* 定义切点,符号切点为全部被@Sjava工程师ingleClick注解的办法
* 留意:这儿 你的包名.SingleClick 需求替换成
* 你自己项目javahdxx中SingleClick这个类的全途径
*/
@Pointcut("execution(@你的包名.Singhttp 404leClick * *(..))")
fun methandroid软件开发odAnnotated(appreciate) { }
/**
* 定义一个切面办法,包裹切点办法
*/
@Around("methodAnnotated()")
@Throws(Throwable::class)
fun aroundJoinPoint(http协议joinPoint: Proceedingjava工程师JoinPoint) {
try {
// 取出办法的注解
val signature = joinPoint.signature as Methojava游戏dSignature
val method = signature.method
// 查看办法是否有注解
val hasAnnotatiogradle下载慢解决办法n = method != null && method.isAnnotationPreandroid是什么手机牌子sent(SingleClick::class.java)
if (hajava初学sAnnotatigradle是什么on) {
// 核算点击距离,没有注解默许500,有注解appear按注解参数来,android/yunos注解参数为空默许500;
val singleClick = method.getAnnotation(SingleClick::class.java)
val interval = singleClick.value
// 检测距离时间是否抵达预设时间而且线程闲暇
if (canClick(interval)) {
joiappstorenPoint.proceed()
}
} else {
joinPoint.proceed()
}
} catch (e: Exception) {
// 出现异常不阻挠点击事件
joinPoint.proceed()
}
}
// 判断是否照应点击
private fun canClick(interval: Long): Boolean {
val tgradle依靠坐标怎样找ime = SystemCloandroid的drawable类ck.elapsedRejava工程师alhttp://192.168.1.1登录time()
val timeIandroidstudio安装教程nterval = Mathappear.abs(time - mLastClickTime)
if (timeIntergradle发音val &gradle依靠坐标怎样找gt; interval) {
mLastClickTime = time
return true
}
returandroid什么意思n fAndroidalse
}
companion object {
// 最终一次点击的时gradle翻译刻
privgradle发音ate var mLastClickTime: Longgradle = 0
}
}
build.gradle(android平板电脑价格项目):
buildscriptappreciate {
dependencies {
classpath 'com.huandroid/yunosjiang.aspectjx:gradle-android-plugin-aspejava根底知识点ctjx:2.0.4'
}
}
build.gradle(APP):
plugins {
id 'android-ajava怎样读spectjx'
}
运用:http 302
<?xmJaval version="1.0" encodiandroid什么意思ng="utf-8"?>
<androidx.constraintgradle是什么layout.widget.ConstraintLayout xmlns:android="http://schemas.androandroid的drawable类id.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xgradle翻译mlns:tools="http://schemas.ajava环境变量装备ndrhttp://www.baidu.comoid.com/tools"
android:layout_javaeewidth="match_parent"
android:layout_height="match_parent"
tools:context=android/yunos".MainActivity">
<Textgradle打包View
android:onClick="onTextClick"
android:layouandroid什么意思t_width="wrap_content"
android:layout_heightjavahdxx="wrap_content"
android:text="Hello World!"
app:appstorelayout_constAndroidraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_candroid什么意思onstraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.Conshttp协议traintLayouhttps和http的差异t>
class MainActivity : AppCompagradletActivity() {
override fun onCreate(android下载savedInstanceSgradle下载慢解决办法tate: Bundle?) {
super.onCreate(savedInstanceState)
sethttp 302ContentView(R.lgradle下载ayout.activity_main)
}
@SingleClick(800)
fun onThttp://192.168.1.1登录extClick(view: View) {
}
}