|
|
@@ -14,7 +14,9 @@ import io.reactivex.disposables.Disposable;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import kr.co.zumo.app.R;
|
|
|
import kr.co.zumo.app.lifeplus.bean.SignUpMobileAuthorizationBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.MobileAuthorizationBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.MobileAuthorizationConfirmBean;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.network.api.LifeplusAPIService;
|
|
|
import kr.co.zumo.app.lifeplus.util.AppUtil;
|
|
|
@@ -44,10 +46,14 @@ public class MobileAuthorizationPresenter {
|
|
|
private IMobileAuthorizationDialog view;
|
|
|
|
|
|
private String authorizationNumber;
|
|
|
+ private DialogBase dialog;
|
|
|
|
|
|
public MobileAuthorizationPresenter(IMobileAuthorizationDialog iMobileAuthorizationDialog) {
|
|
|
this.view = iMobileAuthorizationDialog;
|
|
|
|
|
|
+ view.setEnabledRequestConfirmTextView(false);
|
|
|
+ view.setEnabledRequestConfirmButton(false);
|
|
|
+
|
|
|
// default setting
|
|
|
userBean.setMobileCompany(ResourceUtil.getStringArray("mobile_companies")[0]);
|
|
|
userBean.setFirstPhoneNumber(ResourceUtil.getStringArray("phone_numbers")[0]);
|
|
|
@@ -65,17 +71,16 @@ public class MobileAuthorizationPresenter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private IDialogResultListener resultListener;
|
|
|
-
|
|
|
- public void setResultListener(IDialogResultListener resultListener) {
|
|
|
- this.resultListener = resultListener;
|
|
|
- }
|
|
|
-
|
|
|
public void dispose() {
|
|
|
if (null != disposable) {
|
|
|
disposable.dispose();
|
|
|
disposable = null;
|
|
|
}
|
|
|
+
|
|
|
+ if (null != dialog) {
|
|
|
+ dialog.dismiss();
|
|
|
+ dialog = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void doHideKeyBoard() {
|
|
|
@@ -104,9 +109,8 @@ public class MobileAuthorizationPresenter {
|
|
|
public void onNameTextChanged(String inputName) {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | doNameValidationMessage", "|" + inputName);
|
|
|
|
|
|
- verifyName(inputName);
|
|
|
userBean.setName(inputName);
|
|
|
-
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -116,7 +120,7 @@ public class MobileAuthorizationPresenter {
|
|
|
*/
|
|
|
public void onFocusNameText(boolean isFocusChanged) {
|
|
|
if (isFocusChanged) {
|
|
|
- verifyName(userBean.getName());
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
else {
|
|
|
view.doClearNameValidationTextView();
|
|
|
@@ -132,8 +136,8 @@ public class MobileAuthorizationPresenter {
|
|
|
public void onBirthDateTextChanged(String inputBirthDate) {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | onBirthDateTextChanged", "|" + inputBirthDate);
|
|
|
|
|
|
- verifyBirthDate(inputBirthDate);
|
|
|
userBean.setBirthDate(inputBirthDate);
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -143,7 +147,7 @@ public class MobileAuthorizationPresenter {
|
|
|
*/
|
|
|
public void onFocusBirthDateText(boolean isFocusChanged) {
|
|
|
if (isFocusChanged) {
|
|
|
- verifyBirthDate(userBean.getBirthDate());
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
else {
|
|
|
view.doClearBirthDateValidationTextView();
|
|
|
@@ -158,8 +162,8 @@ public class MobileAuthorizationPresenter {
|
|
|
public void onPhoneNumberTextChanged(String phoneNumber) {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | onPhoneNumberCheckedValidationMessage", "|" + phoneNumber);
|
|
|
|
|
|
- verifyPhoneNumber(phoneNumber);
|
|
|
userBean.setPhoneNumber(phoneNumber);
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -169,7 +173,7 @@ public class MobileAuthorizationPresenter {
|
|
|
*/
|
|
|
public void onFocusPhoneNumberText(boolean isFocusChanged) {
|
|
|
if (isFocusChanged) {
|
|
|
- verifyPhoneNumber(userBean.getPhoneNumber());
|
|
|
+ verifyRequestNumberButton();
|
|
|
}
|
|
|
else {
|
|
|
view.doClearPhoneNumberValidationTextView();
|
|
|
@@ -273,7 +277,7 @@ public class MobileAuthorizationPresenter {
|
|
|
public void onAuthorizedNumberChanged(String authorizedNumber) {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | onPhoneNumberCheckedValidationMessage", "|" + authorizedNumber);
|
|
|
verifyAuthorizationNumber(authorizedNumber);
|
|
|
- authorizationNumber = authorizedNumber;
|
|
|
+ this.authorizationNumber = authorizedNumber;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -283,27 +287,88 @@ public class MobileAuthorizationPresenter {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | onAuthorizationConfirmButtonClick", "|" + "click");
|
|
|
|
|
|
boolean isValidated = true;
|
|
|
- if (verifyAuthorizationNumber(authorizationNumber) == false) {
|
|
|
+ if (verifyAuthorizationNumber(this.authorizationNumber) == false) {
|
|
|
isValidated = false;
|
|
|
}
|
|
|
|
|
|
if (isValidated) {
|
|
|
// call api...
|
|
|
+
|
|
|
+ MobileAuthorizationConfirmBean bean = new MobileAuthorizationConfirmBean();
|
|
|
+ bean.setDeviceUuid(SuperModel.getInstance().getDeviceUuid());
|
|
|
+ bean.setAuthorizationNumber(this.authorizationNumber);
|
|
|
+
|
|
|
+ disposable.add(
|
|
|
+ LifeplusAPIService.requestMobileAuthorization(bean)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(resultBean -> {
|
|
|
+ Log.i("APP# MobileAuthorizationPresenter | onAuthorizationConfirmButtonClick", "|" + resultBean.toPrettyJson());
|
|
|
+ // todo 결과 비교해서 성공/실패 처리
|
|
|
+ doSomeWhenConfirmSuccess(resultBean);
|
|
|
+ }, e -> {
|
|
|
+ if (AppUtil.isDebug()) {
|
|
|
+ LifeplusAPIBean resultBean = new LifeplusAPIBean();
|
|
|
+ resultBean.setCode("0");
|
|
|
+ resultBean.setReturnMessage("OK");
|
|
|
+ doSomeWhenConfirmSuccess(resultBean);
|
|
|
+ }
|
|
|
+ else if (e instanceof HttpException) {
|
|
|
+ showSendingPopup(R.string.phone_identify_submit_message_fail);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ showInvalidateConfirmPopup(R.string.phone_identify_number_need);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 인증번호 발송 버튼 클릭, 인증 번호 발송 전 user 정보 data 준비.
|
|
|
- */
|
|
|
- public void onAuthorizationNumberSendButtonClick() {
|
|
|
- Log.i("APP# MobileAuthorizationPresenter | onAuthorizationNumberSendButtonClick", "|" + userBean.toPrettyJson());
|
|
|
+ private void doSomeWhenConfirmSuccess(LifeplusAPIBean bean) {
|
|
|
|
|
|
/**
|
|
|
- * 유효성 체크
|
|
|
- * - 실패 시 해당 위치로 이동
|
|
|
- * - 통과하면 api 호출
|
|
|
+ * // todo 아래 코드는 팝업 외에서 처리해야 한다.
|
|
|
+ * 2. 성공 시 PROCESS 진입
|
|
|
+ 1) 만 14세 이상 : 약관동의(JO2001)화면 링크
|
|
|
+ 2) 14세 미만 : 14세 미만 가입불가 안내 (JO5002) 화면 링크
|
|
|
+ 3) 회원 Y: 기존회원 간편암호 확인 안내 (JO5002) 화면 링크
|
|
|
+ 4) 회원탈퇴일 기준 30일 이내 Y
|
|
|
+ - 탈퇴 회원 (30일 이내) 가입불가 안내 (JO5003) 화면 링크
|
|
|
*/
|
|
|
|
|
|
+ view.onResultDelegate(new Event.Builder(Event.SUCCESS).json(bean.toJson()).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showInvalidateConfirmPopup(@StringRes int stringId) {
|
|
|
+ dialog = DialogBuilder.create(DialogID.ALERT)
|
|
|
+ .listener(new IDialogResultListener() {
|
|
|
+ @Override
|
|
|
+ public void onDialogResult(DialogBase dialog, Event event) {
|
|
|
+ if (event.getEventId() == Event.CONFIRM) {
|
|
|
+ dialog.dismiss();
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(DialogBase dialog) {
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .attribute((IAttribute<AlertDialog>) dialog -> {
|
|
|
+ dialog.setText(ResourceUtil.getString(stringId));
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void verifyRequestNumberButton() {
|
|
|
+
|
|
|
+ boolean isValidated = verifyRequestNumberValidation();
|
|
|
+
|
|
|
+ view.setEnabledRequestNumberButton(isValidated);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean verifyRequestNumberValidation() {
|
|
|
boolean isValidated = true;
|
|
|
if (verifyName(userBean.getName()) == false) {
|
|
|
isValidated = false;
|
|
|
@@ -321,6 +386,23 @@ public class MobileAuthorizationPresenter {
|
|
|
isValidated = false;
|
|
|
}
|
|
|
|
|
|
+ return isValidated;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 인증번호 발송 버튼 클릭, 인증 번호 발송 전 user 정보 data 준비.
|
|
|
+ */
|
|
|
+ public void onAuthorizationNumberSendButtonClick() {
|
|
|
+ Log.i("APP# MobileAuthorizationPresenter | onAuthorizationNumberSendButtonClick", "|" + userBean.toPrettyJson());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 유효성 체크
|
|
|
+ * - 실패 시 해당 위치로 이동
|
|
|
+ * - 통과하면 api 호출
|
|
|
+ */
|
|
|
+
|
|
|
+ boolean isValidated = verifyRequestNumberValidation();
|
|
|
+
|
|
|
if (isValidated) {
|
|
|
// call api...
|
|
|
Log.w("APP# MobileAuthorizationPresenter | onAuthorizationNumberSendButtonClick", "|" + "call api ============ ");
|
|
|
@@ -344,12 +426,15 @@ public class MobileAuthorizationPresenter {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(resultBean -> {
|
|
|
Log.i("APP# MobileAuthorizationPresenter | onAuthorizationNumberSendButtonClick", "|" + resultBean.toPrettyJson());
|
|
|
+ // todo 결과 비교해서 성공/실패 처리
|
|
|
doSomeWhenSendingSuccess();
|
|
|
}, e -> {
|
|
|
if (AppUtil.isDebug()) {
|
|
|
doSomeWhenSendingSuccess();
|
|
|
}
|
|
|
else if (e instanceof HttpException) {
|
|
|
+ view.setEnabledRequestConfirmTextView(false);
|
|
|
+ view.setEnabledRequestConfirmButton(false);
|
|
|
showSendingPopup(R.string.phone_identify_submit_message_fail);
|
|
|
}
|
|
|
})
|
|
|
@@ -358,6 +443,8 @@ public class MobileAuthorizationPresenter {
|
|
|
}
|
|
|
|
|
|
private void doSomeWhenSendingSuccess() {
|
|
|
+ view.setEnabledRequestConfirmTextView(true);
|
|
|
+
|
|
|
showSendingPopup(R.string.phone_identify_submit_message_success);
|
|
|
|
|
|
view.showRemainTime(true);
|
|
|
@@ -390,17 +477,19 @@ public class MobileAuthorizationPresenter {
|
|
|
}
|
|
|
|
|
|
private void showSendingPopup(@StringRes int stringId) {
|
|
|
- DialogBuilder.create(DialogID.ALERT)
|
|
|
+ dialog = DialogBuilder.create(DialogID.ALERT)
|
|
|
.listener(new IDialogResultListener() {
|
|
|
@Override
|
|
|
public void onDialogResult(DialogBase dialog, Event event) {
|
|
|
if (event.getEventId() == Event.CONFIRM) {
|
|
|
dialog.dismiss();
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onDialogCanceled(DialogBase dialog) {
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
}
|
|
|
})
|
|
|
.attribute((IAttribute<AlertDialog>) dialog -> {
|
|
|
@@ -433,15 +522,17 @@ public class MobileAuthorizationPresenter {
|
|
|
*/
|
|
|
public void onClickAgreeDetail(int index) {
|
|
|
// todo index 에 따른 디테일 화면 웹뷰 표시
|
|
|
- DialogBuilder.create(DialogID.WEB)
|
|
|
+ dialog = DialogBuilder.create(DialogID.WEB)
|
|
|
.listener(new IDialogResultListener() {
|
|
|
@Override
|
|
|
public void onDialogResult(DialogBase dialog, Event event) {
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onDialogCanceled(DialogBase dialog) {
|
|
|
+ MobileAuthorizationPresenter.this.dialog = null;
|
|
|
|
|
|
}
|
|
|
})
|
|
|
@@ -449,11 +540,6 @@ public class MobileAuthorizationPresenter {
|
|
|
.show();
|
|
|
}
|
|
|
|
|
|
- public void onCancel(DialogBase dialog) {
|
|
|
- resultListener.onDialogCanceled(dialog);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/***********************************
|
|
|
* Validation - after request Number
|
|
|
***********************************/
|