1、在项目的build.gradle中的buildscript中的dependencies添加:
dependencies {
...
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
classpath 'org.aspectj:aspectjtools:1.9.2'
classpath 'org.aspectj:aspectjweaver:1.9.2'
}
2、在项目的build.gradle中的allprojects中的repositories添加:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
3、在app的build.gradle中的最上面添加
apply plugin: 'android-aspectjx'
4、在app的build.gradle中的dependencies添加
implementation 'com.guangcai.singleclick:singleclick:1.0.0'
@SingleClick
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnClick:
Toast.makeText(this,"啊啊啊啊",Toast.LENGTH_SHORT).show()
break;
}
}
@SingleClick
override fun onClick(v: View?) {
if (v != null) {
when(v.id){
R.id.btnClick ->{
Toast.makeText(this,"哈哈哈哈",Toast.LENGTH_SHORT).show()
}
}
}
}
@SingleClick(1000)
override fun onClick(v: View?) {
if (v != null) {
when(v.id){
R.id.btnClick ->{
Toast.makeText(this,"呵呵呵呵",Toast.LENGTH_SHORT).show()
}
}
}
}
btn.setSingleCLickListener {
Toast.makeText(this,"啊啊啊啊",Toast.LENGTH_SHORT).show()
}