|
@@ -1,6 +1,7 @@
|
|
|
package com.miekir.mvp.view;
|
|
package com.miekir.mvp.view;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
import androidx.lifecycle.Observer;
|
|
import androidx.lifecycle.Observer;
|
|
@@ -50,10 +51,28 @@ public abstract class BaseMVPActivity extends BaseActivity implements IView {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 参数校验
|
|
|
if (methods != null && methods.length > 0) {
|
|
if (methods != null && methods.length > 0) {
|
|
|
for (Method method : methods) {
|
|
for (Method method : methods) {
|
|
|
DataMethod dataMethod = method.getAnnotation(DataMethod.class);
|
|
DataMethod dataMethod = method.getAnnotation(DataMethod.class);
|
|
|
if (dataMethod != null) {
|
|
if (dataMethod != null) {
|
|
|
|
|
+ int length = method.getParameterTypes().length;
|
|
|
|
|
+ if (length != 3) {
|
|
|
|
|
+ throw new AssertionError("DataMethod参数数量必须为3个");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String firstType = method.getParameterTypes()[0].getSimpleName();
|
|
|
|
|
+ String firstCorrectType = int.class.getSimpleName();
|
|
|
|
|
+ if (!TextUtils.equals(firstCorrectType, firstType)) {
|
|
|
|
|
+ throw new AssertionError("DataMethod第1个参数必须为" + firstCorrectType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String secondType = method.getParameterTypes()[1].getSimpleName();
|
|
|
|
|
+ String secondCorrectType = String.class.getSimpleName();
|
|
|
|
|
+ if (!TextUtils.equals(secondCorrectType, secondType)) {
|
|
|
|
|
+ throw new AssertionError("DataMethod第2个参数必须为" + secondCorrectType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
mDataMethodList.add(method);
|
|
mDataMethodList.add(method);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|