|
@@ -13,6 +13,7 @@ import org.aspectj.lang.annotation.Before;
|
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
|
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,13 +27,26 @@ public class LoadingAspect {
|
|
|
@Pointcut("execution(* *(..)) && @annotation(com.miekir.mvp.base.NeedLoading)")
|
|
@Pointcut("execution(* *(..)) && @annotation(com.miekir.mvp.base.NeedLoading)")
|
|
|
public void timeTask() {}
|
|
public void timeTask() {}
|
|
|
|
|
|
|
|
- /*@Around("timeTask()")
|
|
|
|
|
|
|
+ @Around("timeTask()")
|
|
|
public void onTimeTaskAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
public void onTimeTaskAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
|
- joinPoint.proceed();
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ Object targetObject = joinPoint.getTarget();
|
|
|
|
|
+ Field liveDataField = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ liveDataField = targetObject.getClass().getField("liveData");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (liveDataField != null) {
|
|
|
|
|
+ //如果在Around中不调用joinPoint.proceed(),则@Before注解的方法不会调用,但是@After还是会调用。
|
|
|
|
|
+ joinPoint.proceed();
|
|
|
|
|
+ Log.e(TAG, "proceed....");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Log.e(TAG, "live data null....");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Before("timeTask()")
|
|
@Before("timeTask()")
|
|
|
- public void afterMethod(JoinPoint joinPoint){
|
|
|
|
|
|
|
+ public void beforeMethod(JoinPoint joinPoint){
|
|
|
// 注入加载框
|
|
// 注入加载框
|
|
|
Object targetObject = joinPoint.getTarget();
|
|
Object targetObject = joinPoint.getTarget();
|
|
|
try {
|
|
try {
|
|
@@ -47,6 +61,7 @@ public class LoadingAspect {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
showDialogMethod.invoke(targetObject, message);*/
|
|
showDialogMethod.invoke(targetObject, message);*/
|
|
|
|
|
+
|
|
|
showDialogMethod.invoke(targetObject);
|
|
showDialogMethod.invoke(targetObject);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|