|
|
@@ -0,0 +1,119 @@
|
|
|
+/*
|
|
|
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
|
|
|
+ */
|
|
|
+package kr.co.zumo.app.lifeplus.view.dialog;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.NonNull;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+
|
|
|
+import kr.co.zumo.app.R;
|
|
|
+import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
+import kr.co.zumo.app.lifeplus.view.custom.pin.CustomPinUnlockPresenter;
|
|
|
+import kr.co.zumo.app.lifeplus.view.custom.pin.CustomPinView;
|
|
|
+import kr.co.zumo.app.lifeplus.view.custom.pin.IPinContract;
|
|
|
+
|
|
|
+/**
|
|
|
+ * PinUnlockDialog
|
|
|
+ * <pre>
|
|
|
+ * 핀 입력이 완료되면 onDialogResult(this, Event.string(pin)) 으로 입력 값이 전달된다.
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @author 민효동
|
|
|
+ * @version 1.0
|
|
|
+ * @history 민효동 [2018. 11. 1.] [최초 작성]
|
|
|
+ * @since 2018. 11. 1.
|
|
|
+ */
|
|
|
+public class PinUnlockDialog extends DialogBase {
|
|
|
+
|
|
|
+ private CustomPinView customPinView;
|
|
|
+ private IPinContract.Presenter pinPresenter;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ super.onDestroyView();
|
|
|
+
|
|
|
+ if (null != customPinView) {
|
|
|
+ customPinView.dispose();
|
|
|
+ customPinView = null;
|
|
|
+ }
|
|
|
+ if (null != pinPresenter) {
|
|
|
+ pinPresenter.dispose();
|
|
|
+ pinPresenter = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Nullable
|
|
|
+ @Override
|
|
|
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
|
|
+ return inflater.inflate(R.layout.view_container, container, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityCreated(Bundle savedInstanceState) {
|
|
|
+ super.onActivityCreated(savedInstanceState);
|
|
|
+
|
|
|
+ getDialog().getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
|
|
|
+
|
|
|
+ customPinView = new CustomPinView(getContext());
|
|
|
+ pinPresenter = new CustomPinUnlockPresenter(customPinView, new IPinContract.Listener() {
|
|
|
+ @Override
|
|
|
+ public void onPinResult(String result) {
|
|
|
+ if (null != getResultListener()) {
|
|
|
+ getResultListener().onDialogResult(PinUnlockDialog.this, new Event.Builder(Event.CONFIRM).string(result).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClickPinReset() {
|
|
|
+ if (null != getResultListener()) {
|
|
|
+ getResultListener().onDialogResult(PinUnlockDialog.this, new Event.Builder(Event.RESET).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClickClose() {
|
|
|
+ if (null != getResultListener()) {
|
|
|
+ getResultListener().onDialogCanceled(PinUnlockDialog.this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPinFail() {
|
|
|
+ if (null != getResultListener()) {
|
|
|
+ getResultListener().onDialogResult(PinUnlockDialog.this, new Event.Builder(Event.FAIL).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPinHelp() {
|
|
|
+ if (null != getResultListener()) {
|
|
|
+ getResultListener().onDialogResult(PinUnlockDialog.this, new Event.Builder(Event.HELP).build());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ View parent = getView();
|
|
|
+ ViewGroup layout = parent.findViewById(R.id.container);
|
|
|
+ ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
+ layout.addView(customPinView, params);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 핀 입력 재시도
|
|
|
+ * - 5회 실패 시 onPinFail() 발생하여 Event.FAIL 이 전달된다.
|
|
|
+ */
|
|
|
+ public void retry() {
|
|
|
+ pinPresenter.retry();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|