|
|
@ -61,23 +61,44 @@ public class RecipientEditV3Presenter extends RecipientAddEditBaseV3Presenter { |
|
|
|
|
|
|
|
view.updateValueToWidgetSelectedCountry(selectedCountry.getCountryName()); |
|
|
|
view.showSelectedCountryFlag(CountryFlagMapper.getFlagFromCountryCode(selectedCountry.getCountryCode())); |
|
|
|
|
|
|
|
flushCountryRelatedDataOnCountryServiceSelected(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void flushCountryRelatedDataOnCountryServiceSelected() { |
|
|
|
view.updateValueToWidgetSelectedPaymentMethod(""); |
|
|
|
view.updateValueToWidgetBankName(""); |
|
|
|
view.updateValueToWidgetBranchName(""); |
|
|
|
|
|
|
|
validator.getRecipientDetail().setPaymentMethod(null); |
|
|
|
validator.getRecipientDetail().setAgent(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onServiceTypeSelected(ServiceTypeModel selectedServiceType) { |
|
|
|
// validator.clearExistinInfoExceptRecipientId(); |
|
|
|
validator.getRecipientDetail().updateSelectedCountry(validator.getSelectedCountryServiceData()); |
|
|
|
validator.getRecipientDetail().setPaymentMethod(new PaymentMethodV3Model(selectedServiceType.getId(), selectedServiceType.getText(), selectedServiceType.getDescription())); |
|
|
|
|
|
|
|
view.updateValueToWidgetSelectedPaymentMethod(selectedServiceType.getDescription()); |
|
|
|
|
|
|
|
flushPaymentMethodRelatedDataOnServiceTypeSelected(); |
|
|
|
|
|
|
|
|
|
|
|
//TODO Right now mock |
|
|
|
|
|
|
|
//getDynamicValidationAndDropDownList(); |
|
|
|
mockDynamicValidaitonList(); |
|
|
|
} |
|
|
|
|
|
|
|
private void flushPaymentMethodRelatedDataOnServiceTypeSelected() { |
|
|
|
view.updateValueToWidgetBankName(""); |
|
|
|
view.updateValueToWidgetBranchName(""); |
|
|
|
|
|
|
|
validator.getRecipientDetail().setAgent(null); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 1. Get CountryService Detail |
|
|
@ -134,9 +155,9 @@ public class RecipientEditV3Presenter extends RecipientAddEditBaseV3Presenter { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void getDynamicValidationAndDropDownList() { |
|
|
|
private void getDynamicValidationAndDropDownList(String countryId, String serviceType) { |
|
|
|
compositeDisposable.add( |
|
|
|
this.gateway.getCountryServiceDetail(gateway.getAuth()) |
|
|
|
this.gateway.getDynamicValidationRules(gateway.getAuth(), gateway.getUserID(), countryId, serviceType) |
|
|
|
.doOnSubscribe(disposable -> view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) |
|
|
|
.doFinally(() -> view.showProgressBar(false, "")) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
@ -150,15 +171,13 @@ public class RecipientEditV3Presenter extends RecipientAddEditBaseV3Presenter { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void seedExistingDatatoView() { |
|
|
|
|
|
|
|
|
|
|
|
view.updateValueToWidgetSelectedCountry(validator.getRecipientDetail().getCountry()); |
|
|
|
view.showSelectedCountryFlag(CountryFlagMapper.getFlagFromCountryCode(validator.getRecipientDetail().getCountryCode())); |
|
|
|
if (validator.getRecipientDetail().getPaymentMethod() != null) |
|
|
|
view.updateValueToWidgetSelectedPaymentMethod(validator.getRecipientDetail().getPaymentMethod().getName()); |
|
|
|
view.showSelectedCountryFlag(CountryFlagMapper.getFlagFromCountryCode(validator.getRecipientDetail().getCountryCode())); |
|
|
|
|
|
|
|
view.updateValueToWidgetIDNumber(validator.getRecipientDetail().getIdNumber()); |
|
|
|
|
|
|
@ -204,14 +223,22 @@ public class RecipientEditV3Presenter extends RecipientAddEditBaseV3Presenter { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class DynamicListObserver extends GenericApiObserverResponseV2<List<ValidationRuleModel>> { |
|
|
|
public class DynamicListObserver extends GenericApiObserverResponseV2<DynamicValidationModel> { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onSuccess(GenericResponseDataModel<List<ValidationRuleModel>> t) { |
|
|
|
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
applyValidationRulesToView(t.getData()); |
|
|
|
protected void onSuccess(GenericResponseDataModel<DynamicValidationModel> data) { |
|
|
|
if (data.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
validator.updateDynamicValidationModel(data.getData()); |
|
|
|
|
|
|
|
//Map existing data to view and validator |
|
|
|
|
|
|
|
view.showCountrySelectionView(true); |
|
|
|
view.showPaymentSelectionView(true); |
|
|
|
applyValidationRulesToView(data.getData().getValidationRuleList()); |
|
|
|
validator.validateAllRequiredFieldsExplicitly(); |
|
|
|
|
|
|
|
} else { |
|
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
view.showPopUpMessage(data.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -242,26 +269,32 @@ public class RecipientEditV3Presenter extends RecipientAddEditBaseV3Presenter { |
|
|
|
@Override |
|
|
|
protected void onSuccess(GenericResponseDataModel<List<CountryServiceModel>> t) { |
|
|
|
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
persistAvailableCountryServiceList(t.getData()); |
|
|
|
validator.updateAvailableCountryServiceData(t.getData()); |
|
|
|
seedExistingDatatoView(); |
|
|
|
String countryId = validator.getRecipientDetail().getCountryId(); |
|
|
|
String serviceTypeID = validator.getRecipientDetail().getPaymentMethod().getId(); |
|
|
|
getDynamicValidationAndDropDownList(countryId, serviceTypeID); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailed(String message) { |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void unauthorizedAccess(String message) { |
|
|
|
gateway.clearAllUserData(); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|