|
|
@@ -12,20 +12,12 @@ import android.view.View;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-
|
|
|
-import io.reactivex.Completable;
|
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
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.MobileAuthBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
|
|
|
import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
|
|
|
import kr.co.zumo.app.lifeplus.model.SignUpModel;
|
|
|
-import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
import kr.co.zumo.app.lifeplus.util.Formatter;
|
|
|
import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
@@ -126,95 +118,88 @@ public class SignUpMobileAuthPresenter extends SignUpFragmentPresenter {
|
|
|
protected void onEventInternal(Event event) {
|
|
|
switch (event.getEventId()) {
|
|
|
case Event.CONFIRM:
|
|
|
- onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_PIN, ScreenID.DIRECTION_NEXT));
|
|
|
+ if (event.getInteger() == Event.MEMBER_AUTH) {
|
|
|
+ // 가입 완료 토스트 종료 쯤 전달.
|
|
|
+ onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_PIN, ScreenID.DIRECTION_NEXT));
|
|
|
+ }
|
|
|
break;
|
|
|
case Event.SUCCESS:
|
|
|
- Log.i("APP# SignUpMobileAuthPresenter | onEventInternal", "|" + "resultString: " + event.getJson());
|
|
|
- onAuthResult(event);
|
|
|
+ if (event.getInteger() == Event.MEMBER_AUTH) {
|
|
|
+ // 가입 완료 즉시 전달.
|
|
|
+ onAuthResult();
|
|
|
+ }
|
|
|
+ else if (event.getInteger() == Event.MEMBER_UNDER_14YEARS) {
|
|
|
+ //14세 미만
|
|
|
+ onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_UNDER_14_YEARS, ScreenID.DIRECTION_NEXT));
|
|
|
+ }
|
|
|
+ else if (event.getInteger() == Event.MEMBER_ALREADY_MEMBER) {
|
|
|
+ // 이미 회원
|
|
|
+ onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_ALREADY_MEMBER, ScreenID.DIRECTION_NEXT));
|
|
|
+ }
|
|
|
+ else if (event.getInteger() == Event.MEMBER_NEED_30DAYS) {
|
|
|
+ // 30일이내 가입
|
|
|
+ onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_NEED_FOR_30DAYS, ScreenID.DIRECTION_NEXT));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log.i("APP# SignUpMobileAuthPresenter | onEventInternal", "|" + "resultString: " + event.getJson());
|
|
|
+ model.onAuthResult(event);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Event.ERROR:
|
|
|
+ // error
|
|
|
+ if (event.getInteger() == Event.MEMBER_AUTH) {
|
|
|
+ showPopup();
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void onAuthResult(Event event) {
|
|
|
- MobileAuthBean mobileAuthBean = event.fromJson(MobileAuthBean.class);
|
|
|
- LifeplusAPIBean resultBean = new Gson().fromJson(event.getString(), LifeplusAPIBean.class);
|
|
|
-
|
|
|
- Log.w("APP# SignUpMobileAuthPresenter | onEventInternal", "| 인증 결과: " + resultBean.toPrettyJson());
|
|
|
- Log.w("APP# SignUpMobileAuthPresenter | onEventInternal", "| 유저 데이터: " + mobileAuthBean.toPrettyJson());
|
|
|
-
|
|
|
- /**
|
|
|
- * 2. 성공 시 PROCESS 진입
|
|
|
- 1) 만 14세 이상 : 약관동의(JO2001)화면 링크
|
|
|
- 2) 14세 미만 : 14세 미만 가입불가 안내 (JO5002) 화면 링크
|
|
|
- 3) 회원 Y: 기존회원 간편암호 확인 안내 (JO5002) 화면 링크
|
|
|
- 4) 회원탈퇴일 기준 30일 이내 Y
|
|
|
- - 탈퇴 회원 (30일 이내) 가입불가 안내 (JO5003) 화면 링크
|
|
|
- */
|
|
|
- if (resultBean.isSuccess()) {
|
|
|
- Context context = App.getInstance().getContext();
|
|
|
- Toast toast = new Toast(context);
|
|
|
- toast.setDuration(Toast.LENGTH_SHORT);
|
|
|
- toast.setGravity(Gravity.FILL, 0, 0);
|
|
|
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
- View view = inflater.inflate(R.layout.sign_up_auth_result_dialog, null);
|
|
|
- ((TextView) view.findViewById(R.id.text_view_authorization_result_name)).setText(mobileAuthBean.getName());
|
|
|
- ((TextView) view.findViewById(R.id.text_view_authorization_result_gender)).setText(mobileAuthBean.getGender());
|
|
|
- ((TextView) view.findViewById(R.id.text_view_authorization_result_birth_date)).setText(
|
|
|
- Formatter.format(mobileAuthBean.getBirthDate(), MobileAuthBean.BIRTH_DATE_FORMAT, "yyyy.mm.dd")
|
|
|
- );
|
|
|
- String phoneNumber = mobileAuthBean.getFirstPhoneNumber() + mobileAuthBean.getPhoneNumber();
|
|
|
- Log.i("APP# SignUpMobileAuthPresenter | onAuthResult", "| b: " + phoneNumber);
|
|
|
- Log.i("APP# SignUpMobileAuthPresenter | onAuthResult", "| a: " + StringUtil.formatPhoneNumber(phoneNumber));
|
|
|
- ((TextView) view.findViewById(R.id.text_view_authorization_result_phone_number)).setText(
|
|
|
- StringUtil.formatPhoneNumber(phoneNumber)
|
|
|
- );
|
|
|
- toast.setView(view);
|
|
|
- toast.show();
|
|
|
-
|
|
|
- // 신규 가입
|
|
|
- model.setMobileAuthorizationBean(mobileAuthBean);
|
|
|
- model.checkMobileAuthorized();
|
|
|
-
|
|
|
- disposable = Completable.timer(2000, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
|
|
- .subscribe(() -> {
|
|
|
- onEvent(new Event.Builder(Event.CONFIRM).build());
|
|
|
- }, Throwable::printStackTrace);
|
|
|
- }
|
|
|
- else if (resultBean.getCode() == LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_UNDER_14_YEARS) {
|
|
|
- //14세 미만
|
|
|
- onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_UNDER_14_YEARS, ScreenID.DIRECTION_NEXT));
|
|
|
- }
|
|
|
- else if (resultBean.getCode() == LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_ALREADY_MEMBER) {
|
|
|
- // 이미 회원
|
|
|
- onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_ALREADY_MEMBER, ScreenID.DIRECTION_NEXT));
|
|
|
- }
|
|
|
- else if (resultBean.getCode() == LifeplusAPIBean.RETURN_MOBILE_AUTH_ERROR_NEED_FOR_30_DAYS) {
|
|
|
- // 30일이내 가입
|
|
|
- SuperModel.getInstance().addMemberStatus(SuperModel.MEMBER_STATUS_BIT_OUT);
|
|
|
- onCommand(new FragmentChangeCommand(ScreenID.SIGN_UP_NEED_FOR_30DAYS, ScreenID.DIRECTION_NEXT));
|
|
|
- }
|
|
|
- else {
|
|
|
- // 알 수 없는 에러;
|
|
|
- dialog = DialogBuilder.create(DialogID.CONFIRM)
|
|
|
- .listener(new IDialogResultListener() {
|
|
|
- @Override
|
|
|
- public void onDialogResult(DialogBase dialog, Event event) {
|
|
|
- if (event.getEventId() == Event.CONFIRM) {
|
|
|
- dialog.dispose();
|
|
|
- }
|
|
|
+ private void showPopup() {
|
|
|
+ dialog = DialogBuilder.create(DialogID.CONFIRM)
|
|
|
+ .listener(new IDialogResultListener() {
|
|
|
+ @Override
|
|
|
+ public void onDialogResult(DialogBase dialog, Event event) {
|
|
|
+ if (event.getEventId() == Event.CONFIRM) {
|
|
|
+ dialog.dispose();
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(DialogBase dialog) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .attribute((IAttribute<ConfirmDialog>) dialog -> {
|
|
|
+ dialog.setText(ResourceUtil.getString(R.string.undefined_error));
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void onAuthResult() {
|
|
|
+ MobileAuthBean mobileAuthBean = model.getMobileAuthorizationBean();
|
|
|
+
|
|
|
+ Context context = App.getInstance().getContext();
|
|
|
+ Toast toast = new Toast(context);
|
|
|
+ toast.setDuration(Toast.LENGTH_SHORT);
|
|
|
+ toast.setGravity(Gravity.FILL, 0, 0);
|
|
|
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+ View view = inflater.inflate(R.layout.sign_up_auth_result_dialog, null);
|
|
|
+ ((TextView) view.findViewById(R.id.text_view_authorization_result_name)).setText(mobileAuthBean.getName());
|
|
|
+ ((TextView) view.findViewById(R.id.text_view_authorization_result_gender)).setText(mobileAuthBean.getGender());
|
|
|
+ ((TextView) view.findViewById(R.id.text_view_authorization_result_birth_date)).setText(
|
|
|
+ Formatter.format(mobileAuthBean.getBirthDate(), MobileAuthBean.BIRTH_DATE_FORMAT, "yyyy.mm.dd")
|
|
|
+ );
|
|
|
+ String phoneNumber = mobileAuthBean.getFirstPhoneNumber() + mobileAuthBean.getPhoneNumber();
|
|
|
+ Log.i("APP# SignUpMobileAuthPresenter | onAuthResult", "| b: " + phoneNumber);
|
|
|
+ Log.i("APP# SignUpMobileAuthPresenter | onAuthResult", "| a: " + StringUtil.formatPhoneNumber(phoneNumber));
|
|
|
+ ((TextView) view.findViewById(R.id.text_view_authorization_result_phone_number)).setText(
|
|
|
+ StringUtil.formatPhoneNumber(phoneNumber)
|
|
|
+ );
|
|
|
+ toast.setView(view);
|
|
|
+ toast.show();
|
|
|
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(DialogBase dialog) {
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute((IAttribute<ConfirmDialog>) dialog -> {
|
|
|
- dialog.setText(ResourceUtil.getString(R.string.undefined_error));
|
|
|
- })
|
|
|
- .show();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|