Skip to content

Commit

Permalink
feat:移除aspect & 升级gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
hejiajun committed Mar 25, 2022
1 parent c935501 commit 1fc4ca0
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 84 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.application'
//apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'android-aspectjx'
//apply plugin: 'android-aspectjx'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
Expand Down Expand Up @@ -77,7 +77,7 @@ dependencies {
exclude group: 'com.github.bumptech.glide', module: 'glide'
}
implementation librarys.glide
implementation librarys.aspect
// implementation librarys.aspect
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation files('lib/aip-java-sdk-4.11.3.jar')
implementation files('lib/json-20160810.jar')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
* Created by HeJiaJun on 2019/6/25.
* Email:455hejiajun@gmail
* des:
*
* @deprecated 由于agp不兼容,移除了aspect
*/
@Deprecated()
public class AspectButtonActivity extends Activity {


Expand Down
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
package com.returntolife.jjcode.mydemolist.demo.function.AspectButton;

import android.view.View;

import com.tools.jj.tools.utils.LogUtil;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;

/**
* Created by HeJiaJun on 2019/6/25.
* Email:455hejiajun@gmail
* des:
*/
@Aspect
public class SingleClickAspect {
private static final long DEFAULT_TIME_INTERVAL = 5000;

/**
* 定义切点,标记切点为所有被@SingleClick注解的方法
* 注意:这里me.baron.test.annotation.SingleClick需要替换成
* 你自己项目中SingleClick这个类的全路径哦
*/
@Pointcut("execution(@com.returntolife.jjcode.mydemolist.demo.function.AspectButton.SingleClick * *(..))")
public void methodAnnotated() {}


@Around("execution(* com.returntolife.jjcode.mydemolist.demo.function.AspectButton.AspectButtonActivity.test())")
public void noParam(ProceedingJoinPoint joinPoint) throws Throwable{
//joinPoint.proceed(); //方法继续执行
}

/**
* 定义一个切面方法,包裹切点方法
*/
@Around("methodAnnotated()")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
// 取出方法的参数
View view = null;
for (Object arg : joinPoint.getArgs()) {
if (arg instanceof View) {
view = (View) arg;
break;
}
}
if (view == null) {
return;
}
// 取出方法的注解
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
if (!method.isAnnotationPresent(SingleClick.class)) {
return;
}
SingleClick singleClick = method.getAnnotation(SingleClick.class);
LogUtil.d("singleClick="+singleClick.value());
// 判断是否快速点击
if (!XClickUtil.isFastDoubleClick(view, singleClick.value())) {
// 不是快速点击,执行原方法
joinPoint.proceed();
}
}
}
//package com.returntolife.jjcode.mydemolist.demo.function.AspectButton;
//
//import android.view.View;
//
//import com.tools.jj.tools.utils.LogUtil;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//
//import java.lang.reflect.Method;
//
///**
// * Created by HeJiaJun on 2019/6/25.
// * Email:455hejiajun@gmail
// * des:
// */
//@Aspect
//public class SingleClickAspect {
// private static final long DEFAULT_TIME_INTERVAL = 5000;
//
// /**
// * 定义切点,标记切点为所有被@SingleClick注解的方法
// * 注意:这里me.baron.test.annotation.SingleClick需要替换成
// * 你自己项目中SingleClick这个类的全路径哦
// */
// @Pointcut("execution(@com.returntolife.jjcode.mydemolist.demo.function.AspectButton.SingleClick * *(..))")
// public void methodAnnotated() {}
//
//
// @Around("execution(* com.returntolife.jjcode.mydemolist.demo.function.AspectButton.AspectButtonActivity.test())")
// public void noParam(ProceedingJoinPoint joinPoint) throws Throwable{
// //joinPoint.proceed(); //方法继续执行
// }
//
// /**
// * 定义一个切面方法,包裹切点方法
// */
// @Around("methodAnnotated()")
// public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
// // 取出方法的参数
// View view = null;
// for (Object arg : joinPoint.getArgs()) {
// if (arg instanceof View) {
// view = (View) arg;
// break;
// }
// }
// if (view == null) {
// return;
// }
// // 取出方法的注解
// MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
// Method method = methodSignature.getMethod();
// if (!method.isAnnotationPresent(SingleClick.class)) {
// return;
// }
// SingleClick singleClick = method.getAnnotation(SingleClick.class);
// LogUtil.d("singleClick="+singleClick.value());
// // 判断是否快速点击
// if (!XClickUtil.isFastDoubleClick(view, singleClick.value())) {
// // 不是快速点击,执行原方法
// joinPoint.proceed();
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*/
public class DemoListDataManager {

private volatile static DemoListDataManager instance;
private static final DemoListDataManager instance=new DemoListDataManager();


private List<DemoListBean> demoListBeanList;
Expand All @@ -70,14 +70,6 @@ private DemoListDataManager(){
}

public static DemoListDataManager getInstance(){
if(instance==null){
synchronized (DemoListDataManager.class){
if(instance==null){
instance=new DemoListDataManager();
}
}

}
return instance;
}

Expand All @@ -101,7 +93,7 @@ private void initDemoListData() {
demoListBeanList.add(new DemoListBean("AIDL","AIDL的使用","2019-05-31",R.drawable.bg_test1,DemoListBean.TYPE_FUNCTION, AIDLClientActivity.class));
demoListBeanList.add(new DemoListBean("注解注入","mvp模式中用注解注入p层","2019-06-01",R.drawable.bg_annotate,DemoListBean.TYPE_FUNCTION, AnnotateActivity.class));
demoListBeanList.add(new DemoListBean("多布局列表","自定义adapter","2019-06-01",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, MultiItemActivity.class));
demoListBeanList.add(new DemoListBean("Aspect","按钮重复点击限制","2019-06-25",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, AspectButtonActivity.class));
// demoListBeanList.add(new DemoListBean("Aspect","按钮重复点击限制","2019-06-25",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, AspectButtonActivity.class));
demoListBeanList.add(new DemoListBean("MVVM","简单的demo","2019-07-04",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, MvvmDemoActivity.class));
demoListBeanList.add(new DemoListBean("图像识别","基于百度AI","2019-08-01",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, ImageSearchActivity.class));
demoListBeanList.add(new DemoListBean("仿饿了么点餐滑动效果","recyclerview联动","2019-08-26",R.drawable.bg_md_test,DemoListBean.TYPE_FUNCTION, SectionActivity.class));
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.0'
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
runner : "com.android.support.test:runner:1.0.2",
espresso : "com.android.support.test.espresso:espresso-core:3.0.2",
glide : "com.github.bumptech.glide:glide:4.7.1",
aspect : "org.aspectj:aspectjrt:1.8.9",
// aspect : "org.aspectj:aspectjrt:1.8.9",

kotlin_stdlib : "org.jetbrains.kotlin:kotlin-stdlib:1.3.21",
kotlin_anko_common: "org.jetbrains.kotlin:kotlin-android-extensions:1.3.21",
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 comments on commit 1fc4ca0

Please sign in to comment.