|
|
@@ -2,12 +2,16 @@ package com.miekir.newmvp;
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.miekir.mvp.base.NeedLoading;
|
|
|
+
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
import org.aspectj.lang.annotation.After;
|
|
|
import org.aspectj.lang.annotation.Around;
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.annotation.Before;
|
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
|
+import org.aspectj.lang.reflect.MethodSignature;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
@@ -27,13 +31,22 @@ public class LoadingAspect {
|
|
|
joinPoint.proceed();
|
|
|
}*/
|
|
|
|
|
|
- @After("timeTask()")
|
|
|
+ @Before("timeTask()")
|
|
|
public void afterMethod(JoinPoint joinPoint){
|
|
|
// 注入加载框
|
|
|
Object targetObject = joinPoint.getTarget();
|
|
|
try {
|
|
|
- Method m = targetObject.getClass().getMethod("showLoading");
|
|
|
- m.invoke(targetObject);
|
|
|
+ Method showDialogMethod = targetObject.getClass().getMethod("showLoading", String.class);
|
|
|
+ String message = "";
|
|
|
+
|
|
|
+ Method taskMethod = ((MethodSignature)joinPoint.getSignature()).getMethod();
|
|
|
+ if (taskMethod.isAnnotationPresent(NeedLoading.class)) {
|
|
|
+ NeedLoading loading = taskMethod.getAnnotation(NeedLoading.class);
|
|
|
+ if (loading != null) {
|
|
|
+ message = loading.message();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showDialogMethod.invoke(targetObject, message);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|