|
|
@@ -87,7 +87,23 @@ public class CouponMallPresenter extends Presenter<CouponMallModel, ICouponMallV
|
|
|
|
|
|
@Override
|
|
|
public void onResult(Event event) {
|
|
|
-
|
|
|
+ switch (event.getEventId()) {
|
|
|
+ case Event.SUCCESS:
|
|
|
+ String price = model.getPrice();
|
|
|
+ String unavailableCoin = model.getUnavailableCoin();
|
|
|
+ if (Integer.parseInt(price) > 0) {
|
|
|
+ showAvailableCoinPopup(price, unavailableCoin);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ showErrorDialog(R.string.invalid_data);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Event.ERROR:
|
|
|
+ showErrorDialog(event.getString());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -172,41 +188,61 @@ public class CouponMallPresenter extends Presenter<CouponMallModel, ICouponMallV
|
|
|
* @param purchaseId
|
|
|
*/
|
|
|
public void onRefundSelected(String purchaseId) {
|
|
|
- if (null == purchaseCancelDialog) {
|
|
|
- Log.i("APP# Presenter | onRefundSelected", "|" + " purchaseId -------- " + purchaseId);
|
|
|
- purchaseCancelDialog = new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(getFragmentManager(), DialogID.CONFIRM)
|
|
|
- .listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
- @Override
|
|
|
- public void onPositiveResult(ConfirmDialog dialog, Event event) {
|
|
|
- purchaseCancelDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 취소함
|
|
|
- view.performRefundConfirm();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNegativeResult(ConfirmDialog dialog, Event event) {
|
|
|
- purchaseCancelDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 취소 안함
|
|
|
- view.performRefundCancel();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(ConfirmDialog dialog) {
|
|
|
- purchaseCancelDialog = null;
|
|
|
- dialog.dispose();
|
|
|
- // 취소 안함
|
|
|
- view.performRefundCancel();
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setTitleId(R.string.coupon_purchase_cancel_title);
|
|
|
- dialog.setText(ResourceUtil.getString(R.string.coupon_purchase_cancel_message));
|
|
|
- dialog.setNegativeButtonLabelId(R.string.coupon_purchase_cancel_no);
|
|
|
- dialog.setPositiveButtonLabelId(R.string.coupon_purchase_cancel_yes);
|
|
|
- })
|
|
|
- .show();
|
|
|
+ Log.i("APP# Presenter | onRefundSelected", "|" + " purchaseId -------- " + purchaseId);
|
|
|
+ model.loadAvailableCoin(purchaseId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showAvailableCoinPopup(String price, String unavailableCoin) {
|
|
|
+ if (null == purchaseCancelDialog) {
|
|
|
+ String text;
|
|
|
+ int priceValue = Integer.parseInt(price);
|
|
|
+ int unavailableCoinValue = Integer.parseInt(unavailableCoin);
|
|
|
+ if (unavailableCoinValue == 0) {
|
|
|
+ // 전체 환불
|
|
|
+ text = ResourceUtil.getString(R.string.coupon_purchase_cancel_message);
|
|
|
+ }
|
|
|
+ else if (priceValue == unavailableCoinValue) {
|
|
|
+ // 전체 불가
|
|
|
+ text = ResourceUtil.getString(R.string.coupon_purchase_cancel_message_anything, StringUtil.toComma(unavailableCoinValue));
|
|
|
}
|
|
|
+ else {
|
|
|
+ // 부분 가능
|
|
|
+ text = ResourceUtil.getString(R.string.coupon_purchase_cancel_message_partially, StringUtil.toComma(priceValue), StringUtil.toComma(unavailableCoinValue));
|
|
|
+ }
|
|
|
+
|
|
|
+ purchaseCancelDialog = new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(getFragmentManager(), DialogID.CONFIRM)
|
|
|
+ .listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
+ @Override
|
|
|
+ public void onPositiveResult(ConfirmDialog dialog, Event event) {
|
|
|
+ purchaseCancelDialog = null;
|
|
|
+ dialog.dispose();
|
|
|
+ // 취소함
|
|
|
+ view.performRefundConfirm();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNegativeResult(ConfirmDialog dialog, Event event) {
|
|
|
+ purchaseCancelDialog = null;
|
|
|
+ dialog.dispose();
|
|
|
+ // 취소 안함
|
|
|
+ view.performRefundCancel();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(ConfirmDialog dialog) {
|
|
|
+ purchaseCancelDialog = null;
|
|
|
+ dialog.dispose();
|
|
|
+ // 취소 안함
|
|
|
+ view.performRefundCancel();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .attribute(dialog -> {
|
|
|
+ dialog.setTitleId(R.string.coupon_purchase_cancel_title);
|
|
|
+ dialog.setText(text);
|
|
|
+ dialog.setNegativeButtonLabelId(R.string.coupon_purchase_cancel_no);
|
|
|
+ dialog.setPositiveButtonLabelId(R.string.coupon_purchase_cancel_yes);
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
}
|
|
|
}
|