|
|
@@ -4,14 +4,18 @@ import android.content.Context;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import com.tongyu.luck.happywork.AppCacheManager;
|
|
|
+import com.tongyu.luck.happywork.baselibrary.EventConstant;
|
|
|
import com.tongyu.luck.happywork.bean.api.ApiNormalBean;
|
|
|
import com.tongyu.luck.happywork.callback.MvpDataCallBack;
|
|
|
+import com.tongyu.luck.happywork.event.StringEvent;
|
|
|
import com.tongyu.luck.happywork.http.ApiObserver;
|
|
|
import com.tongyu.luck.happywork.http.RetrofitHttpParams;
|
|
|
import com.tongyu.luck.happywork.http.subscribe.LoginSubscribe;
|
|
|
import com.tongyu.luck.happywork.ui.base.BaseModel;
|
|
|
import com.tongyu.luck.happywork.ui.mvp.cclient.contacts.EditPhoneNumContacts;
|
|
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+
|
|
|
public class EditPhoneNumModel extends BaseModel implements EditPhoneNumContacts.IEditPhoneNumModel {
|
|
|
public EditPhoneNumModel(Context mContext) {
|
|
|
super(mContext);
|
|
|
@@ -31,7 +35,7 @@ public class EditPhoneNumModel extends BaseModel implements EditPhoneNumContacts
|
|
|
* @param code
|
|
|
*/
|
|
|
@Override
|
|
|
- public void httpEditPhoneNum(String phoneNum, String code, final MvpDataCallBack<Boolean> callBack) {
|
|
|
+ public void httpEditPhoneNum(final String phoneNum, final String code, final MvpDataCallBack<Boolean> callBack) {
|
|
|
RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
params.put("new_phone", phoneNum);
|
|
|
if (TextUtils.isEmpty(code)) {
|
|
|
@@ -42,6 +46,11 @@ public class EditPhoneNumModel extends BaseModel implements EditPhoneNumContacts
|
|
|
new LoginSubscribe(mContext).requestEditUserPhone(params.getRequestParams(), new ApiObserver<ApiNormalBean>(mContext, true) {
|
|
|
@Override
|
|
|
public void onSuccess(ApiNormalBean data) {
|
|
|
+ if (!TextUtils.isEmpty(code)) {//修改手机号
|
|
|
+ AppCacheManager.getInstance().getMemberModel().setPhone(phoneNum + "");
|
|
|
+ AppCacheManager.getInstance().setMemberModel(AppCacheManager.getInstance().getMemberModel());//刷新本地缓存数据更新状态
|
|
|
+ EventBus.getDefault().post(new StringEvent(EventConstant.EVENT_USER_CHANGE));
|
|
|
+ }
|
|
|
callBack.onData(true);
|
|
|
}
|
|
|
|