|
|
@@ -8,6 +8,7 @@ import androidx.lifecycle.MutableLiveData;
|
|
|
import androidx.lifecycle.Observer;
|
|
|
|
|
|
import com.miekir.mvp.base.BaseActivity;
|
|
|
+import com.miekir.mvp.base.BaseMvpResponse;
|
|
|
import com.miekir.mvp.base.DataResult;
|
|
|
import com.miekir.mvp.presenter.BaseViewModel;
|
|
|
import com.miekir.mvp.presenter.DataMethod;
|
|
|
@@ -122,11 +123,12 @@ public abstract class BaseMvpActivity extends BaseActivity implements IView {
|
|
|
throw new AssertionError(methodAnnotationName + "修饰的方法参数数量必须为4个");
|
|
|
}
|
|
|
|
|
|
- // 响应结果code
|
|
|
+ // 响应结果,必须为int或者boolean
|
|
|
String firstType = method.getParameterTypes()[0].getSimpleName();
|
|
|
String resultCodeType = int.class.getSimpleName();
|
|
|
- if (!TextUtils.equals(resultCodeType, firstType)) {
|
|
|
- throw new AssertionError(methodAnnotationName + "修饰的方法第1个参数必须为" + resultCodeType);
|
|
|
+ String resultStatusType = boolean.class.getSimpleName();
|
|
|
+ if (!TextUtils.equals(resultCodeType, firstType) && !TextUtils.equals(resultStatusType, firstType)) {
|
|
|
+ throw new AssertionError(methodAnnotationName + "修饰的方法第1个参数必须为" + resultCodeType + "或" + resultStatusType);
|
|
|
}
|
|
|
|
|
|
// 响应消息
|
|
|
@@ -193,6 +195,12 @@ public abstract class BaseMvpActivity extends BaseActivity implements IView {
|
|
|
} catch (Exception e) {
|
|
|
//e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
+ try {
|
|
|
+ method.invoke(this, result.getResponseCode() == BaseMvpResponse.COMMON_SUCCESS, result.getMessage(), result.getBean(), result.getSourceCode());
|
|
|
+ } catch (Exception e) {
|
|
|
+ //e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|