|
@@ -1,5 +1,7 @@
|
|
|
package com.cooleshow.usercenter.presenter;
|
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
+
|
|
|
import com.cooleshow.base.bean.QueryParamsConfigBean;
|
|
|
import com.cooleshow.base.common.BaseApplication;
|
|
|
import com.cooleshow.base.data.net.ApiException;
|
|
@@ -18,50 +20,47 @@ import com.cooleshow.usercenter.presenter.contract.BindPasswordContract;
|
|
|
public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.BindPwdView> implements BindPasswordContract.Presenter {
|
|
|
|
|
|
@Override
|
|
|
- public void onBindPwd(String pwd,String nickName) {
|
|
|
+ public void onBindPwd(String pwd, String nickName) {
|
|
|
if (getView() != null) {
|
|
|
getView().showLoading();
|
|
|
}
|
|
|
- addSubscribe(create(UserApi.class).bindPassword(pwd,nickName), new BaseObserver<Object>(getView()) {
|
|
|
- @Override
|
|
|
- protected void onSuccess(Object data) {
|
|
|
- if (getView() != null) {
|
|
|
- getView().onBindSuccess();
|
|
|
+ if (TextUtils.isEmpty(nickName)) {
|
|
|
+ addSubscribe(create(UserApi.class).bindPassword(pwd), new BaseObserver<Object>(getView()) {
|
|
|
+ @Override
|
|
|
+ protected void onSuccess(Object data) {
|
|
|
+ if (getView() != null) {
|
|
|
+ getView().onBindSuccess();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
- super.onError(e);
|
|
|
- if (e instanceof ApiException) {
|
|
|
- ErrorParse.getInstance().parseError(e);
|
|
|
- ApiException apiException = (ApiException) e;
|
|
|
- ToastUtil.getInstance().showShort(apiException.getErrmsg());
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ super.onError(e);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public void queryModifyConfig() {
|
|
|
- getView().showLoading();
|
|
|
- String params = "last_username_month";
|
|
|
- if(BaseApplication.Companion.isTeacherClient()){
|
|
|
- addSubscribe(create(UserApi.class).queryModifyNickConfigForTeacher(params), new BaseObserver<QueryParamsConfigBean>(getView()) {
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addSubscribe(create(UserApi.class).bindPassword(pwd, nickName), new BaseObserver<Object>(getView()) {
|
|
|
@Override
|
|
|
- protected void onSuccess(QueryParamsConfigBean data) {
|
|
|
+ protected void onSuccess(Object data) {
|
|
|
if (getView() != null) {
|
|
|
- getView().queryModifyConfigSuccess(data);
|
|
|
+ getView().onBindSuccess();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(Throwable e) {
|
|
|
super.onError(e);
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
- }else{
|
|
|
- addSubscribe(create(UserApi.class).queryModifyNickConfigForStu(params), new BaseObserver<QueryParamsConfigBean>(getView()) {
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void queryModifyConfig() {
|
|
|
+ getView().showLoading();
|
|
|
+ String params = "last_username_month";
|
|
|
+ if (BaseApplication.Companion.isTeacherClient()) {
|
|
|
+ addSubscribe(create(UserApi.class).queryModifyNickConfigForTeacher(params), new BaseObserver<QueryParamsConfigBean>(getView()) {
|
|
|
@Override
|
|
|
protected void onSuccess(QueryParamsConfigBean data) {
|
|
|
if (getView() != null) {
|
|
@@ -72,6 +71,7 @@ public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.Bi
|
|
|
@Override
|
|
|
public void onError(Throwable e) {
|
|
|
super.onError(e);
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|