使用aspectJ方式 AspectJ处理重复点击过快点击事件
1.项目的gradle导入
dependencies {
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
}
2.app的gradle添加
apply plugin: 'com.hujiang.android-aspectjx'
3.增加ClickGap注解类
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.CONSTRUCTOR,ElementType.METHOD})
public @interface ClickGap {
}
4.SingleClickAspect
@Aspect
public class SingleClickAspect {
private static long clickGapTime = 0;
public static final int CLICK_GAP_RESPONSE = 500;//500ms内不响应
//判断是否应该执行,true执行,false不执行
protected boolean clickGapF