Browse Source

[설정][New] 비밀번호 변경 api 리턴 값 처리 추가 - 기존 비밀번호 틀린 경우

hyodong.min 6 years ago
parent
commit
920366ac92

+ 2 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/Event.java

@@ -152,6 +152,7 @@ public class Event {
   public static final int ON_BOARDING_CONFIRM = 129;
   public static final int ON_BOARDING_SKIP = 130;
   public static final int RELOADED = 131;
+  public static final int REASON = 132;
 
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({
@@ -165,7 +166,7 @@ public class Event {
     MY_FAQ, UPDATE, FILTER, CLOSE, HELP, CONTENTS, MORE, BANNER, RECOMMEND, KAKAO_TALK, FACE_BOOK, CODE_COPY, EVENT, TAG, BOOKMARK, ORDER, DEFAULT, COMPLETE_BUCKET,
     LIKE, FRAGMENT_STACK_EMPTY, OVER_VIEW, SHARE, CALL_INFO, LINK, HOME_PAGE, INSTAGRAM, ADDRESS, SCROLL, SORT, TUTORIAL, CLICK_HTML, LAST, PREV, NEXT, REFRESH, MY_EVENT,
     ING_EVENT, WINNER_ANNOUNCEMENT, COUPON, TODAY, RECT, VOTE, MAIN, SEARCH, ENTRY, IMAGE, DIALOG, URI, AGREE, PUSH, NEWS, WITH_SHOWN, POINT, FOCUS, TEXT,
-    PHOTO, PERMISSION_GRANTED, SUBMIT, NOTICE, WEATHER, COVER, ON_BOARDING_CLOSE, ON_BOARDING_CONFIRM, ON_BOARDING_SKIP, RELOADED
+    PHOTO, PERMISSION_GRANTED, SUBMIT, NOTICE, WEATHER, COVER, ON_BOARDING_CLOSE, ON_BOARDING_CONFIRM, ON_BOARDING_SKIP, RELOADED, REASON
   })
   public @interface ID {}
 

+ 16 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/setting/member/SettingMemberPasswordModel.java

@@ -12,11 +12,11 @@ import java.util.regex.Pattern;
 import io.reactivex.disposables.Disposable;
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.application.App;
-import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
-import kr.co.zumo.app.lifeplus.bean.api.UserNamePassswordRequestBean;
+import kr.co.zumo.app.lifeplus.bean.api.PasswordUpdateResultBean;
+import kr.co.zumo.app.lifeplus.bean.api.UserNamePasswordRequestBean;
 import kr.co.zumo.app.lifeplus.model.Model;
 import kr.co.zumo.app.lifeplus.model.module.APIError;
-import kr.co.zumo.app.lifeplus.model.module.APIModuleListener;
+import kr.co.zumo.app.lifeplus.model.module.APIModuleReasonListener;
 import kr.co.zumo.app.lifeplus.model.module.APIUpdatePasswordModule;
 import kr.co.zumo.app.lifeplus.util.StringUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
@@ -337,6 +337,7 @@ public class SettingMemberPasswordModel extends Model {
       disposableRename = null;
     }
   }
+
   /**
    * 입력된 새 비번이 서로 같은지 확인
    */
@@ -347,12 +348,22 @@ public class SettingMemberPasswordModel extends Model {
   public void updatePassword() {
     stopRename();
 
-    disposableRename = new APIUpdatePasswordModule().call(new UserNamePassswordRequestBean(getUserName(), passwordNew), new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
+    disposableRename = new APIUpdatePasswordModule().call(new UserNamePasswordRequestBean(getUserName(), passwordCurrent, passwordNew), new APIModuleReasonListener<PasswordUpdateResultBean>(waiterCaller) {
       @Override
-      public void onApiSuccess(LifeplusAPIBean resultBean) {
+      public void onApiSuccess(PasswordUpdateResultBean resultBean) {
         onResult(new Event.Builder(Event.RESULT).build());
       }
 
+      @Override
+      public void onApiReason(PasswordUpdateResultBean resultBean) {
+        if (resultBean.getCode() == PasswordUpdateResultBean.RETURN_CURRENT_PASSWORD_MISS_MATCH) {
+          onResult(new Event.Builder(Event.REASON).integer(PasswordUpdateResultBean.RETURN_CURRENT_PASSWORD_MISS_MATCH).build());
+        }
+        else {
+          onResult(new Event.Builder(Event.ERROR).string(resultBean.getReturnMessage()).build());
+        }
+      }
+
       @Override
       public void onApiError(String errorMessage, APIError error) {
         onResult(new Event.Builder(Event.ERROR).string(errorMessage).build());

+ 8 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/setting/member/SettingMemberPasswordPresenter.java

@@ -6,6 +6,7 @@ package kr.co.zumo.app.lifeplus.view.screen.setting.member;
 import android.text.Spanned;
 
 import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.bean.api.PasswordUpdateResultBean;
 import kr.co.zumo.app.lifeplus.model.verify.Verifier;
 import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
@@ -86,6 +87,13 @@ public class SettingMemberPasswordPresenter extends Presenter<SettingMemberPassw
       case Event.RESULT:
         back();
         break;
+      case Event.REASON:
+        if (event.getInteger() == PasswordUpdateResultBean.RETURN_CURRENT_PASSWORD_MISS_MATCH) {
+          // 기존 패스워드 미스매치
+          view.setVisibleValidationPasswordCurrent(true);
+          view.setValidationPasswordCurrent(ResourceUtil.getString(R.string.setting_password_current_validation_miss_match));
+        }
+        break;
       case Event.ERROR:
         showErrorDialog(event.getString());
         break;
@@ -320,8 +328,5 @@ public class SettingMemberPasswordPresenter extends Presenter<SettingMemberPassw
       view.setVisibleValidationPasswordAgain(true);
       view.setValidationPasswordAgain(ResourceUtil.getString(R.string.setting_password_new_again_validation_miss_match));
     }
-
-    // todo api 통신 후 패스워드 변경됐는지 확인
-
   }
 }