|
|
@@ -3,13 +3,7 @@
|
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.view.custom.pin;
|
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-
|
|
|
-import io.reactivex.Completable;
|
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
-import io.reactivex.disposables.CompositeDisposable;
|
|
|
import kr.co.zumo.app.R;
|
|
|
-import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
|
|
|
@@ -23,124 +17,78 @@ import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
* @history 민효동 [2018-10-04] [최초 작성]
|
|
|
* @since 2018-10-04
|
|
|
*/
|
|
|
-public class CustomPinRegisterPresenter implements IPinContract.Presenter {
|
|
|
-
|
|
|
- private IPinContract.View view;
|
|
|
- private IPinContract.Listener listener;
|
|
|
-
|
|
|
- private String pin;
|
|
|
- private int matchCount;
|
|
|
- private CompositeDisposable disposable = new CompositeDisposable();
|
|
|
-
|
|
|
+public class CustomPinRegisterPresenter extends CustomPinPresenter {
|
|
|
|
|
|
public CustomPinRegisterPresenter(IPinContract.View view, IPinContract.Listener listener) {
|
|
|
- this.view = view;
|
|
|
- this.listener = listener;
|
|
|
-
|
|
|
+ super(view, listener);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void start() {
|
|
|
- this.view.setPresenter(this);
|
|
|
+ protected final boolean isCloseButtonVisible() {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onPinStart() {
|
|
|
- view.setCloseButtonVisible(false);
|
|
|
- view.setResetButtonVisible(false);
|
|
|
- view.setHelpButtonVisible(false);
|
|
|
- view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
|
|
|
- view.updateGuideText(R.string.sign_up_register_pin);
|
|
|
- view.updateTitleText(R.string.sign_up_register_pin_title);
|
|
|
- view.restart();
|
|
|
+ protected final boolean isHelpButtonVisible() {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onPinResult(String result) {
|
|
|
- if (StringUtil.isFull(pin)) {
|
|
|
- // 두 번째 등록
|
|
|
- view.setDisabled();
|
|
|
- // 일치하는지 확인
|
|
|
- if (pin.length() == 4 && pin.equals(result)) {
|
|
|
- // 일치 하면 모델에 저장
|
|
|
- setPinCount(0);
|
|
|
- listener.onPinResult(pin);
|
|
|
- }
|
|
|
- else {
|
|
|
- // 일치 하지 않으면 5회 재시도 후
|
|
|
- if (++matchCount < 5) {
|
|
|
- view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
|
|
|
- view.updateGuideText(String.format(ResourceUtil.getString(R.string.pin_miss_match_error_repeat), matchCount));
|
|
|
- view.restart();
|
|
|
- setPinCount(matchCount);
|
|
|
- }
|
|
|
- else {
|
|
|
- /*
|
|
|
- 5회 이상 불일치 시 ‘간편암호가 5회이상 일치하지 않아, 입력값이 초기화됩니다.’ 밸리데이션 문구 1초간 노출
|
|
|
- - 입력값 초기화된 상태로 STEP1로 변경
|
|
|
- */
|
|
|
- setPinCount(matchCount);
|
|
|
- view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
|
|
|
- view.updateGuideText(R.string.pin_miss_match_init);
|
|
|
-
|
|
|
- view.setDisabled();
|
|
|
- disposable.add(
|
|
|
- Completable.timer(1000, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
|
|
- .subscribe(() -> {
|
|
|
- pin = null;
|
|
|
- listener.onPinFail();
|
|
|
-
|
|
|
- }, Throwable::printStackTrace)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- // 처음 입력;
|
|
|
- matchCount = 0;
|
|
|
- pin = result;
|
|
|
- view.setDisabled();
|
|
|
- view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
|
|
|
- view.updateGuideText(R.string.sign_up_register_pin_again);
|
|
|
- view.restart();
|
|
|
- }
|
|
|
+ protected final boolean isResetButtonVisible() {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClickPinReset() {
|
|
|
-
|
|
|
+ protected final int getFailGuideStringId() {
|
|
|
+ return R.string.pin_miss_match_init;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClickClose() {
|
|
|
-
|
|
|
+ protected final int getGuideStringId() {
|
|
|
+ return R.string.sign_up_register_pin;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void retry() {
|
|
|
-
|
|
|
+ protected int getTitleStringId() {
|
|
|
+ return R.string.sign_up_register_pin_title;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClickHelp() {
|
|
|
- listener.onPinHelp();
|
|
|
+ protected final int getGuideTextColorId() {
|
|
|
+ return R.color.C999999;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void dispose() {
|
|
|
- if (null != disposable) {
|
|
|
- disposable.dispose();
|
|
|
- disposable = null;
|
|
|
- }
|
|
|
+ protected final void retryInternal() {
|
|
|
+ // nothing
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void setPinCount(int count) {
|
|
|
- SuperModel.getInstance().getPreferences().setPinCount(count);
|
|
|
+ protected int getGuideRepeatStringId() {
|
|
|
+ return R.string.sign_up_register_pin_again;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getPinCount() {
|
|
|
- return SuperModel.getInstance().getPreferences().getPinCount();
|
|
|
+ protected final void onPinResultInternal(String result) {
|
|
|
+ view.setDisabled();
|
|
|
+ if (StringUtil.isFull(pin)) {
|
|
|
+ // 두 번째 등록
|
|
|
+ // 일치하는지 확인
|
|
|
+ if (pin.length() == 4 && pin.equals(result)) {
|
|
|
+ // 일치 하면 모델에 저장
|
|
|
+ setPinFailCount(0);
|
|
|
+ listener.onPinResult(pin);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ super.retryInternal();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 처음 입력;
|
|
|
+ matchCount = 0;
|
|
|
+ pin = result;
|
|
|
+ view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
|
|
|
+ view.updateGuideText(getGuideRepeatStringId());
|
|
|
+ view.restart();
|
|
|
+ }
|
|
|
}
|
|
|
}
|