|
|
@@ -1,6 +1,7 @@
|
|
|
package com.miekir.mvp.view;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
@@ -58,6 +59,33 @@ public abstract class BaseMVPFragment extends BaseFragment implements IView {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 参数校验
|
|
|
+ if (methods != null && methods.length > 0) {
|
|
|
+ for (Method method : methods) {
|
|
|
+ DataMethod dataMethod = method.getAnnotation(DataMethod.class);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
mInjectPresenters = new ArrayList<>();
|