@Override public void genericAsyncTaskOnSuccess(Object obj) { if (PurpleSQ.isLoadingDialogVisible()) { PurpleSQ.dismissLoadingDialog(); } mPaymentTask = null; if (obj != null && obj instanceof PaymentPayUVo) { PaymentPayUVo paymentPayUVo = (PaymentPayUVo) obj; PaymentPayUVo.PaymentRequstVo mPaymentRequstVo = paymentPayUVo.getRequest(); new PayUTask(mActivity, mPaymentRequstVo).execute((Void) null); } else if (obj != null && obj instanceof CouponsVo) { CouponsVo couponsVo = (CouponsVo) obj; updateUiForCoupon(couponsVo); } else if (obj != null && obj instanceof TransactionVo) { TransactionVo transactionVo = (TransactionVo) obj; try { mTransactionVo = transactionVo; PurpleSQ.showLoadingDialog(PaymentActivity.this); mPaymentTask = new PaymentTask(authVo.getToken(), couponCode, mTransactionVo, PaymentActivity.this); mPaymentTask.execute((Void) null); } catch (Exception e) { e.printStackTrace(); Crashlytics.logException(e); } } }
@Override public void genericAsyncTaskOnError(Object obj) { if (PurpleSQ.isLoadingDialogVisible()) { PurpleSQ.dismissLoadingDialog(); } mPaymentTask = null; if (obj instanceof ErrorVo) { ErrorVo errorVo = (ErrorVo) obj; if (errorVo.getCode() == 400) { try { JSONObject json = new JSONObject(errorVo.getBody()); if (!TextUtils.isEmpty(json.getString("message"))) { ((EditText) findViewById(R.id.activity_payment_et_coupon)) .setError(json.getString("message")); } else { ((EditText) findViewById(R.id.activity_payment_et_coupon)) .setError(errorVo.getMessage()); } } catch (JSONException e) { e.printStackTrace(); ((EditText) findViewById(R.id.activity_payment_et_coupon)).setError(errorVo.getMessage()); } isErrorSet = true; findViewById(R.id.activity_payment_et_coupon).requestFocus(); } else { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(PSQConsts.DIALOG_FRAGMENT_ERROR); if (prev != null) { ft.remove(prev); } ErrorDialogFragment errorDialogFragment = ErrorDialogFragment.newInstance(errorVo); errorDialogFragment.show(ft, "error_dialog"); } } }
@Override public void genericAsyncTaskOnCancelled(Object obj) { if (PurpleSQ.isLoadingDialogVisible()) { PurpleSQ.dismissLoadingDialog(); } }