|
|
@@ -4,8 +4,6 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.presenter;
|
|
|
|
|
|
import android.support.annotation.IntRange;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.support.annotation.StringRes;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
@@ -24,8 +22,6 @@ import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.ContentsWebDeliveryBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.EventDeliveryBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.UtilityActivityBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.BestBucketBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.BucketWithTagBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.EmergencyBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.EventDetailBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
|
|
|
@@ -62,11 +58,8 @@ import kr.co.zumo.app.lifeplus.view.command.ScreenCommand;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.AlertDialog;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.ConfirmDialog;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.DialogBase;
|
|
|
-import kr.co.zumo.app.lifeplus.view.dialog.DialogBuilder;
|
|
|
-import kr.co.zumo.app.lifeplus.view.dialog.DialogID;
|
|
|
-import kr.co.zumo.app.lifeplus.view.dialog.ICustomConfirmListener;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.DialogProvider;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.ICustomDialogListener;
|
|
|
-import kr.co.zumo.app.lifeplus.view.dialog.PinConfirmDialog;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.event.EventDetailDelegate;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.main.SystemPopupManager;
|
|
|
|
|
|
@@ -87,7 +80,7 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
protected Command command;
|
|
|
protected FirebaseAnalyticsHelper firebaseAnalyticsHelper;
|
|
|
|
|
|
- private DialogBase dialog;
|
|
|
+ private DialogBase dialogError;
|
|
|
private DialogBase dialogNetwork;
|
|
|
private DialogBase pinDialog;
|
|
|
private LoadingDriver waiter;
|
|
|
@@ -167,9 +160,9 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
public final void destroy() {
|
|
|
Log.i("APP# Presenter | destroy", "|" + "<<------------------------- " + this.getClass().getSimpleName());
|
|
|
|
|
|
- if (null != dialog) {
|
|
|
- dialog.dispose();
|
|
|
- dialog = null;
|
|
|
+ if (null != dialogError) {
|
|
|
+ dialogError.dispose();
|
|
|
+ dialogError = null;
|
|
|
}
|
|
|
if (null != pinDialog) {
|
|
|
pinDialog.dispose();
|
|
|
@@ -405,35 +398,12 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
}
|
|
|
|
|
|
protected void showErrorDialog(String string, Runnable runnable, @StringRes int buttonLabelId) {
|
|
|
- dialog = new DialogBuilder<AlertDialog, ICustomDialogListener>(getFragmentManager(), DialogID.ALERT)
|
|
|
- .listener(new ICustomDialogListener<AlertDialog>() {
|
|
|
- @Override
|
|
|
- public void onDialogResult(AlertDialog dialog, Event event) {
|
|
|
- if (event.getEventId() == Event.CONFIRM) {
|
|
|
- dialog.dispose();
|
|
|
- }
|
|
|
-
|
|
|
- if (null != runnable) {
|
|
|
- runnable.run();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(AlertDialog dialog) {
|
|
|
- dialog.dispose();
|
|
|
-
|
|
|
- if (null != runnable) {
|
|
|
- runnable.run();
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setText(string);
|
|
|
- if (buttonLabelId != R.string.empty_string) {
|
|
|
- dialog.setPositiveButtonLabelId(buttonLabelId);
|
|
|
- }
|
|
|
- })
|
|
|
- .show();
|
|
|
+ dialogError = DialogProvider.of(getFragmentManager()).showErrorDialog(string, () -> {
|
|
|
+ dialogError = null;
|
|
|
+ if (null != runnable) {
|
|
|
+ runnable.run();
|
|
|
+ }
|
|
|
+ }, buttonLabelId);
|
|
|
}
|
|
|
|
|
|
protected FragmentManager getFragmentManager() {
|
|
|
@@ -582,50 +552,15 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
|
|
|
protected void confirmPin(Runnable doAfterConfirm, Runnable doAfterFail, Runnable doAfterCancel, boolean hasResetButton) {
|
|
|
// PinConfirmDialog
|
|
|
- pinDialog = new DialogBuilder<PinConfirmDialog, ICustomDialogListener>(getFragmentManager(), DialogID.PIN_CONFIRM)
|
|
|
- .listener(new ICustomDialogListener<PinConfirmDialog>() {
|
|
|
- @Override
|
|
|
- public void onDialogResult(PinConfirmDialog dialog, Event event) {
|
|
|
- switch (event.getEventId()) {
|
|
|
- case Event.CONFIRM:
|
|
|
- String inputPin = event.getString();
|
|
|
- if (model.verifyPin(inputPin)) {
|
|
|
- dialog.resetPinFailCount();
|
|
|
- dialog.dispose();
|
|
|
- doAfterConfirm.run();
|
|
|
+ pinDialog = DialogProvider.of(getFragmentManager()).showPinConfirm(
|
|
|
+ model,
|
|
|
+ doAfterConfirm,
|
|
|
+ doAfterFail,
|
|
|
+ doAfterCancel,
|
|
|
+ () -> go(ScreenID.PIN_RESET_AUTH),
|
|
|
+ () -> onCommand(new EmailSendingCommand(ResourceUtil.getString(R.string.lifeplus_email))),
|
|
|
+ hasResetButton);
|
|
|
|
|
|
- }
|
|
|
- else {
|
|
|
- dialog.retry();
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- case Event.FAIL:
|
|
|
- // 핀 불일치
|
|
|
- doAfterFail.run();
|
|
|
- break;
|
|
|
- case Event.RESET:
|
|
|
- dialog.dispose();
|
|
|
- go(ScreenID.PIN_RESET_AUTH);
|
|
|
- break;
|
|
|
- case Event.HELP:
|
|
|
- // 이메일 문의
|
|
|
- onCommand(new EmailSendingCommand(ResourceUtil.getString(R.string.lifeplus_email)));
|
|
|
- break;
|
|
|
- default:
|
|
|
- dialog.dispose();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(PinConfirmDialog dialog) {
|
|
|
- dialog.dispose();
|
|
|
- doAfterCancel.run();
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> dialog.setResetButtonVisible(hasResetButton))
|
|
|
- .show();
|
|
|
}
|
|
|
|
|
|
/***********************************
|
|
|
@@ -633,83 +568,29 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
***********************************/
|
|
|
protected void showPopupForGuest() {
|
|
|
// 비회원 가입 유도
|
|
|
- new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(getFragmentManager(), DialogID.CONFIRM)
|
|
|
- .listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
- @Override
|
|
|
- public void onPositiveResult(ConfirmDialog dialog, Event event) {
|
|
|
- dialog.dispose();
|
|
|
- go(ScreenID.SIGN_UP_START);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNegativeResult(ConfirmDialog dialog, Event event) {
|
|
|
- dialog.dispose();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(ConfirmDialog dialog) {
|
|
|
- dialog.dispose();
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setText(ResourceUtil.getString(R.string.only_user_service));
|
|
|
- dialog.setPositiveButtonLabelId(R.string.member_confirm);
|
|
|
- })
|
|
|
- .show();
|
|
|
+ DialogProvider.of(getFragmentManager()).showPopupForGuest(() -> go(ScreenID.SIGN_UP_START));
|
|
|
}
|
|
|
|
|
|
/***********************************
|
|
|
* Popup - multi device
|
|
|
***********************************/
|
|
|
- protected ConfirmDialog multiDeviceDialog;
|
|
|
+ private ConfirmDialog multiDeviceDialog;
|
|
|
|
|
|
- protected void showPopupMultiDevice() {
|
|
|
+ private void showPopupMultiDevice() {
|
|
|
if (null == multiDeviceDialog) {
|
|
|
Log.i("APP# Presenter | showPopupMultiDevice", "|" + " showPopupMultiDevice --------");
|
|
|
- multiDeviceDialog = new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(getFragmentManager(), DialogID.CONFIRM)
|
|
|
- .listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
- @Override
|
|
|
- public void onPositiveResult(ConfirmDialog dialog, Event event) {
|
|
|
- multiDeviceDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 잠금 화면으로 이동
|
|
|
- go(ScreenID.PIN_RESET_AUTH_FROM_MULTI_DEVICE);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNegativeResult(ConfirmDialog dialog, Event event) {
|
|
|
- multiDeviceDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 앱 종료
|
|
|
- onCommand(new ExitCommand());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(ConfirmDialog dialog) {
|
|
|
- multiDeviceDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 앱 종료
|
|
|
- onCommand(new ExitCommand());
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setTitleId(R.string.emergency_multi_device_title);
|
|
|
- dialog.setText(ResourceUtil.getString(R.string.emergency_multi_device));
|
|
|
- dialog.setNegativeButtonLabelId(R.string.emergency_multi_device_button_negative);
|
|
|
- dialog.setPositiveButtonLabelId(R.string.emergency_multi_device_button_positive);
|
|
|
- })
|
|
|
- .show();
|
|
|
+ multiDeviceDialog = DialogProvider.of(getFragmentManager()).showPopupMultiDevice(() -> {
|
|
|
+ multiDeviceDialog = null;
|
|
|
+ // 잠금 화면으로 이동
|
|
|
+ go(ScreenID.PIN_RESET_AUTH_FROM_MULTI_DEVICE);
|
|
|
+ }, () -> {
|
|
|
+ multiDeviceDialog = null;
|
|
|
+ // 앱 종료
|
|
|
+ onCommand(new ExitCommand());
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private BucketDeliveryBean getBucketDeliveryBean(@NonNull @ScreenID.ID @IntRange(from = 0, to = 1000) int id, @Nullable BestBucketBean bestBucketBean, @Nullable BucketWithTagBean bean) {
|
|
|
- BucketDeliveryBean bucketDeliveryBean = new BucketDeliveryBean();
|
|
|
- bucketDeliveryBean.setScreenId(id);
|
|
|
- bucketDeliveryBean.setBestBucketBean(bestBucketBean);
|
|
|
- bucketDeliveryBean.setBucketWithTagBean(bean);
|
|
|
- return bucketDeliveryBean;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/***********************************
|
|
|
* navigation
|
|
|
@@ -850,38 +731,32 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
}
|
|
|
else {
|
|
|
if (null == dialogNetwork) {
|
|
|
- dialogNetwork = new DialogBuilder<AlertDialog, ICustomDialogListener>(getFragmentManager(), DialogID.ALERT)
|
|
|
- .listener(new ICustomDialogListener<AlertDialog>() {
|
|
|
- @Override
|
|
|
- public void onDialogResult(AlertDialog dialog, Event event) {
|
|
|
- if (event.getEventId() == Event.BACK) {
|
|
|
- dialogNetwork.dispose();
|
|
|
- onCommand(new ExitCommand());
|
|
|
- }
|
|
|
- else {
|
|
|
- dialogNetwork.dispose();
|
|
|
- dialogNetwork = null;
|
|
|
+ dialogNetwork = DialogProvider.of(getFragmentManager()).showNetworkError(new ICustomDialogListener<AlertDialog>() {
|
|
|
+ @Override
|
|
|
+ public void onDialogResult(AlertDialog dialog, Event event) {
|
|
|
+ if (event.getEventId() == Event.BACK) {
|
|
|
+ dialogNetwork.dispose();
|
|
|
+ onCommand(new ExitCommand());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ dialogNetwork.dispose();
|
|
|
+ dialogNetwork = null;
|
|
|
|
|
|
- showNetworkBarrier();
|
|
|
+ showNetworkBarrier();
|
|
|
|
|
|
- isDoingNetworkCheck = true;
|
|
|
- model.checkNetwork();
|
|
|
- }
|
|
|
+ isDoingNetworkCheck = true;
|
|
|
+ model.checkNetwork();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(AlertDialog dialog) {
|
|
|
- dialogNetwork = null;
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setCancelable(false);
|
|
|
- dialog.setText(R.string.network_disconnected_message_detail_dialog);
|
|
|
- dialog.setPositiveButtonLabelId(R.string.retry);
|
|
|
- })
|
|
|
- .show();
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(AlertDialog dialog) {
|
|
|
+ dialogNetwork = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
isDoingNetworkCheck = false;
|
|
|
}
|
|
|
|
|
|
@@ -891,8 +766,6 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
@Override
|
|
|
public void onApiEmergency(IEmergency emergency) {
|
|
|
/*
|
|
|
- todo presenter 와 screen starter 의 emergency 중복 코드 제거 필요
|
|
|
-
|
|
|
멀티 디바이스 사용 등의 경우 api 호출 시 특정 값을 반환하므로 이를 처리한다.
|
|
|
*/
|
|
|
if (emergency.getEmergencyCode() == EmergencyBean.CODE_MULTI_DEVICE) {
|
|
|
@@ -999,8 +872,6 @@ public abstract class Presenter<M extends Model, V extends IView> implements ILi
|
|
|
activityBase.openDrawer();
|
|
|
activityBase.setVisibleTextButton(false == model.isActiveMember());
|
|
|
|
|
|
- //model.setDeliveryPackaging(model.getScreenId());
|
|
|
- // go(ScreenID.ALL_MENU);
|
|
|
}
|
|
|
|
|
|
/**
|