|
@ -64,7 +64,7 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View. |
|
|
ImageView recepientFlagImageView; |
|
|
ImageView recepientFlagImageView; |
|
|
|
|
|
|
|
|
private boolean shouldCaulatedByRecipient; |
|
|
private boolean shouldCaulatedByRecipient; |
|
|
private boolean shouldCalculateExRate=true; |
|
|
|
|
|
|
|
|
private boolean shouldCalculateExRate = true; |
|
|
|
|
|
|
|
|
CompositeDisposable compositeDisposable = null; |
|
|
CompositeDisposable compositeDisposable = null; |
|
|
|
|
|
|
|
@ -188,25 +188,20 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View. |
|
|
// { |
|
|
// { |
|
|
// showToastMessage("Please specify sending amount."); |
|
|
// showToastMessage("Please specify sending amount."); |
|
|
// } |
|
|
// } |
|
|
//TODO remove && false |
|
|
|
|
|
if(shouldCalculateExRate&&false) |
|
|
|
|
|
{ |
|
|
|
|
|
if(shouldCaulatedByRecipient&&!validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (shouldCalculateExRate) { |
|
|
|
|
|
if (shouldCaulatedByRecipient && !validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) { |
|
|
showToastMessage("Please specify either of the amount."); |
|
|
showToastMessage("Please specify either of the amount."); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if(!shouldCaulatedByRecipient&&!validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if (!shouldCaulatedByRecipient && !validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) { |
|
|
showToastMessage("Please specify either of the amount."); |
|
|
showToastMessage("Please specify either of the amount."); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
getForex(); |
|
|
getForex(); |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if(validateAll()) { |
|
|
|
|
|
((SendMoneyActionListener) getActivity()).getPresenter().setSendingAmount(sendMoneyEditText.getText().toString(),selectedsendingCurrency,selectedExRate,selectedRecipientAmount,selectedTransferFeeAmount,shouldCaulatedByRecipient,selectedExRateId); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (validateAll()) { |
|
|
|
|
|
((SendMoneyActionListener) getActivity()).getPresenter().setSendingAmount(sendMoneyEditText.getText().toString(), selectedsendingCurrency, selectedExRate, selectedRecipientAmount, selectedTransferFeeAmount, shouldCaulatedByRecipient, selectedExRateId); |
|
|
((SendMoneyV2Activity) getActivity()).addScreenToSendMoney(R.layout.fragment_verification_send_money_v2, true); |
|
|
((SendMoneyV2Activity) getActivity()).addScreenToSendMoney(R.layout.fragment_verification_send_money_v2, true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -237,252 +232,269 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View. |
|
|
this.recepientCurrencyTextView.setText(selectedCountryCurrency); |
|
|
this.recepientCurrencyTextView.setText(selectedCountryCurrency); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void showTransferfeeAndExRate(String transferDisplay, String exRateDisplay) { |
|
|
|
|
|
|
|
|
|
|
|
this.exchangeRateTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
this.exchangeRateTxtView.setText(exRateDisplay); |
|
|
|
|
|
this.exchangeRateTxtView.setTranslationY(this.exchangeRateTxtView.getHeight()); |
|
|
|
|
|
this.exchangeRateTxtView.setVisibility(View.VISIBLE); |
|
|
|
|
|
ViewCompat.animate(this.exchangeRateTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start(); |
|
|
|
|
|
|
|
|
private void showTransferfeeAndExRate(boolean action, String transferDisplay, String exRateDisplay) { |
|
|
|
|
|
|
|
|
this.transferFeeTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
this.transferFeeTxtView.setText(transferDisplay); |
|
|
|
|
|
this.transferFeeTxtView.setTranslationY(this.transferFeeTxtView.getHeight()); |
|
|
|
|
|
this.transferFeeTxtView.setVisibility(View.VISIBLE); |
|
|
|
|
|
ViewCompat.animate(this.transferFeeTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (action) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.exchangeRateTxtView.getVisibility() == View.VISIBLE) |
|
|
|
|
|
this.exchangeRateTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
this.exchangeRateTxtView.setText(exRateDisplay); |
|
|
|
|
|
this.exchangeRateTxtView.setTranslationY(this.exchangeRateTxtView.getHeight()); |
|
|
|
|
|
this.exchangeRateTxtView.setVisibility(View.VISIBLE); |
|
|
|
|
|
ViewCompat.animate(this.exchangeRateTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start(); |
|
|
|
|
|
|
|
|
private void showSendAndRecieveAmount(String sendAmount, String recieveAmount) { |
|
|
|
|
|
updateSendAmount(sendAmount); |
|
|
|
|
|
updateRecievingAmount(recieveAmount); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean validateAmountIsNotEmpty(String amount) { |
|
|
|
|
|
return amount != null && amount.length() > 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (this.transferFeeTxtView.getVisibility() == View.VISIBLE) |
|
|
|
|
|
this.transferFeeTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
this.transferFeeTxtView.setText(transferDisplay); |
|
|
|
|
|
this.transferFeeTxtView.setTranslationY(this.transferFeeTxtView.getHeight()); |
|
|
|
|
|
this.transferFeeTxtView.setVisibility(View.VISIBLE); |
|
|
|
|
|
ViewCompat.animate(this.transferFeeTxtView).translationY(0).setDuration(550).setInterpolator(this.interpolator).start(); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onCurrencySelected(RecipientCurrencyModel selectedCurrency) { |
|
|
|
|
|
amountDetailRelatedData.setDefaultSelectedCurrency(selectedCurrency); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (exchangeRateTxtView.getVisibility() == View.VISIBLE) |
|
|
|
|
|
this.exchangeRateTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
|
|
|
if (exRateCountryListingDialog != null) |
|
|
|
|
|
exRateCountryListingDialog.dismiss(); |
|
|
|
|
|
exRateCountryListingDialog = null; |
|
|
|
|
|
|
|
|
if (transferFeeTxtView.getVisibility() == View.VISIBLE) { |
|
|
|
|
|
this.transferFeeTxtView.setVisibility(View.INVISIBLE); |
|
|
|
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(),amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
|
|
|
|
|
switch (v.getId()) { |
|
|
|
|
|
case R.id.sendAmountEdTxt: |
|
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
|
|
|
|
hideKeyBoard(); |
|
|
|
|
|
shouldCaulatedByRecipient = false; |
|
|
|
|
|
if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
getForex(); |
|
|
|
|
|
else |
|
|
|
|
|
showToastMessage("Please specify sending amount."); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
case R.id.receiveAmountEdTxt: |
|
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
|
|
|
|
hideKeyBoard(); |
|
|
|
|
|
shouldCaulatedByRecipient = true; |
|
|
|
|
|
if (validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) |
|
|
|
|
|
getForex(); |
|
|
|
|
|
else |
|
|
|
|
|
showToastMessage("Please specify recieving amount."); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showSendAndRecieveAmount (String sendAmount, String recieveAmount){ |
|
|
|
|
|
updateSendAmount(sendAmount); |
|
|
|
|
|
updateRecievingAmount(recieveAmount); |
|
|
} |
|
|
} |
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> { |
|
|
|
|
|
|
|
|
private boolean validateAmountIsNotEmpty (String amount){ |
|
|
|
|
|
return amount != null && amount.length() > 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { |
|
|
|
|
|
if(isUIReady()) { |
|
|
|
|
|
showProgressBar(false, ""); |
|
|
|
|
|
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
|
|
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData(); |
|
|
|
|
|
selectedTransferFeeAmount = data.getScCharge(); |
|
|
|
|
|
selectedExRate = data.getExRateDisplay(); |
|
|
|
|
|
selectedRecipientAmount = data.getpAmt(); |
|
|
|
|
|
selectedSendAmount = data.getCollAmt(); |
|
|
|
|
|
selectedsendingCurrency = data.getCollCurr(); |
|
|
|
|
|
selectedExRateId=data.getExrateId(); |
|
|
|
|
|
|
|
|
public void onCurrencySelected (RecipientCurrencyModel selectedCurrency){ |
|
|
|
|
|
amountDetailRelatedData.setDefaultSelectedCurrency(selectedCurrency); |
|
|
|
|
|
|
|
|
String transferDisplay = " - " + selectedTransferFeeAmount + " " + selectedsendingCurrency + " (Transfer Fee Included)"; |
|
|
|
|
|
String exRateDisplay = " " + selectedExRate + " (Current Exchange Rate)"; |
|
|
|
|
|
|
|
|
if (exRateCountryListingDialog != null) |
|
|
|
|
|
exRateCountryListingDialog.dismiss(); |
|
|
|
|
|
exRateCountryListingDialog = null; |
|
|
|
|
|
|
|
|
showTransferfeeAndExRate(transferDisplay, exRateDisplay); |
|
|
|
|
|
showSendAndRecieveAmount(selectedSendAmount, selectedRecipientAmount); |
|
|
|
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onEditorAction (TextView v,int actionId, KeyEvent event){ |
|
|
|
|
|
switch (v.getId()) { |
|
|
|
|
|
case R.id.sendAmountEdTxt: |
|
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
|
|
|
|
hideKeyBoard(); |
|
|
|
|
|
shouldCaulatedByRecipient = false; |
|
|
|
|
|
if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
getForex(); |
|
|
|
|
|
else |
|
|
|
|
|
showToastMessage("Please specify sending amount."); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
case R.id.receiveAmountEdTxt: |
|
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|
|
|
|
|
hideKeyBoard(); |
|
|
|
|
|
shouldCaulatedByRecipient = true; |
|
|
|
|
|
if (validateAmountIsNotEmpty(recieveMoneyEditText.getText().toString())) |
|
|
|
|
|
getForex(); |
|
|
|
|
|
else |
|
|
|
|
|
showToastMessage("Please specify recieving amount."); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
} else |
|
|
|
|
|
showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailed(String message) { |
|
|
|
|
|
showProgressBar(false,""); |
|
|
|
|
|
showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { |
|
|
|
|
|
if (isUIReady()) { |
|
|
|
|
|
showProgressBar(false, ""); |
|
|
|
|
|
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|
|
|
|
|
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData(); |
|
|
|
|
|
selectedTransferFeeAmount = data.getScCharge(); |
|
|
|
|
|
selectedExRate = data.getExRateDisplay(); |
|
|
|
|
|
selectedRecipientAmount = data.getpAmt(); |
|
|
|
|
|
selectedSendAmount = data.getCollAmt(); |
|
|
|
|
|
selectedsendingCurrency = data.getCollCurr(); |
|
|
|
|
|
selectedExRateId = data.getExrateId(); |
|
|
|
|
|
|
|
|
|
|
|
String transferDisplay = " - " + selectedTransferFeeAmount + " " + selectedsendingCurrency + " (Transfer Fee Included)"; |
|
|
|
|
|
String exRateDisplay = " " + selectedExRate + " (Current Exchange Rate)"; |
|
|
|
|
|
|
|
|
|
|
|
showTransferfeeAndExRate(true,transferDisplay, exRateDisplay); |
|
|
|
|
|
showSendAndRecieveAmount(selectedSendAmount, selectedRecipientAmount); |
|
|
|
|
|
updateButtonToCalculate(false); |
|
|
|
|
|
|
|
|
|
|
|
} else |
|
|
|
|
|
showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
|
|
showProgressBar(false,""); |
|
|
|
|
|
showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailed(String message) { |
|
|
|
|
|
showProgressBar(false, ""); |
|
|
|
|
|
showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
|
|
showProgressBar(false, ""); |
|
|
|
|
|
showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class AmountDetailRelatedDataObserver extends GenericApiObserverResponse<AmountDetailRelatedDataModel> { |
|
|
|
|
|
|
|
|
public class AmountDetailRelatedDataObserver extends GenericApiObserverResponse<AmountDetailRelatedDataModel> { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) { |
|
|
|
|
|
if (isUIReady()) { |
|
|
|
|
|
amountDetailRelatedData = amountDetailRelatedDataModel; |
|
|
|
|
|
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) |
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onSuccess(AmountDetailRelatedDataModel amountDetailRelatedDataModel) { |
|
|
|
|
|
if (isUIReady()) { |
|
|
|
|
|
amountDetailRelatedData = amountDetailRelatedDataModel; |
|
|
|
|
|
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) |
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
updateButtonToCalculate(true); |
|
|
|
|
|
} |
|
|
|
|
|
scheduleTaskLater(() -> { |
|
|
|
|
|
amountDetailRelatedData = amountDetailRelatedDataModel; |
|
|
|
|
|
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) |
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
updateButtonToCalculate(true); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
scheduleTaskLater(() -> { |
|
|
|
|
|
amountDetailRelatedData = amountDetailRelatedDataModel; |
|
|
|
|
|
if (amountDetailRelatedData.getDefaultSelectedCurrency() != null) |
|
|
|
|
|
showSelectedCurrency(amountDetailRelatedData.getDefaultSelectedCurrency().getCountryCode(), amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailed(String message) { |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailed(String message) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean validateAll() |
|
|
|
|
|
{ |
|
|
|
|
|
if(validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
|
|
|
private boolean validateAll () |
|
|
{ |
|
|
{ |
|
|
if(validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) { |
|
|
|
|
|
if (validateAmountIsNotEmpty(sendMoneyEditText.getText().toString())) |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
showToastMessage("Please specify recieving amount."); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
showToastMessage("Please specify recieving amount."); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
showToastMessage("Please specify sending amount."); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
private void updateButtonToCalculate ( boolean action) |
|
|
{ |
|
|
{ |
|
|
showToastMessage("Please specify sending amount."); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
shouldCalculateExRate = action; |
|
|
|
|
|
if (action) |
|
|
|
|
|
continueBtn.setText("Calculate"); |
|
|
|
|
|
else |
|
|
|
|
|
continueBtn.setText("Continue"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
private void updateButtonToCalculate(boolean action) |
|
|
|
|
|
{ |
|
|
|
|
|
shouldCalculateExRate=action; |
|
|
|
|
|
if(action) |
|
|
|
|
|
continueBtn.setText("Calculate"); |
|
|
|
|
|
else |
|
|
|
|
|
continueBtn.setText("Continue"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateSendAmount(String amount) |
|
|
|
|
|
{ |
|
|
|
|
|
registerAvailableTextWatchersForEditText(sendMoneyEditText,false); |
|
|
|
|
|
sendMoneyEditText.setText(amount); |
|
|
|
|
|
registerAvailableTextWatchersForEditText(sendMoneyEditText,true); |
|
|
|
|
|
} |
|
|
|
|
|
private void updateRecievingAmount(String amount) |
|
|
|
|
|
{ |
|
|
|
|
|
registerAvailableTextWatchersForEditText(recieveMoneyEditText,false); |
|
|
|
|
|
recieveMoneyEditText.setText(amount); |
|
|
|
|
|
registerAvailableTextWatchersForEditText(recieveMoneyEditText,true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void registerTextWatchers(boolean action) { |
|
|
|
|
|
if (action) { |
|
|
|
|
|
if (sendAmountTextWatcher == null) |
|
|
|
|
|
sendAmountTextWatcher = new SendAmountTextWatcher(); |
|
|
|
|
|
if (recepientAmountTextWatcher == null) |
|
|
|
|
|
recepientAmountTextWatcher = new RecipientAmountTextWatcher(); |
|
|
|
|
|
|
|
|
private void updateSendAmount (String amount) |
|
|
|
|
|
{ |
|
|
|
|
|
registerAvailableTextWatchersForEditText(sendMoneyEditText, false); |
|
|
|
|
|
sendMoneyEditText.setText(amount); |
|
|
|
|
|
registerAvailableTextWatchersForEditText(sendMoneyEditText, true); |
|
|
|
|
|
} |
|
|
|
|
|
private void updateRecievingAmount (String amount) |
|
|
|
|
|
{ |
|
|
|
|
|
registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); |
|
|
|
|
|
recieveMoneyEditText.setText(amount); |
|
|
|
|
|
registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
} else { |
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(null); |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(null); |
|
|
|
|
|
|
|
|
private void registerTextWatchers ( boolean action){ |
|
|
|
|
|
if (action) { |
|
|
|
|
|
if (sendAmountTextWatcher == null) |
|
|
|
|
|
sendAmountTextWatcher = new SendAmountTextWatcher(); |
|
|
|
|
|
if (recepientAmountTextWatcher == null) |
|
|
|
|
|
recepientAmountTextWatcher = new RecipientAmountTextWatcher(); |
|
|
|
|
|
|
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
} else { |
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(null); |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(null); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void registerAvailableTextWatchersForEditText(EditText editText, boolean action) { |
|
|
|
|
|
switch (editText.getId()) { |
|
|
|
|
|
case R.id.sendAmountEdTxt: |
|
|
|
|
|
if (action) |
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
else |
|
|
|
|
|
sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
break; |
|
|
|
|
|
case R.id.receiveAmountEdTxt: |
|
|
|
|
|
if (action) |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
else |
|
|
|
|
|
recieveMoneyEditText.removeTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
private void registerAvailableTextWatchersForEditText (EditText editText,boolean action){ |
|
|
|
|
|
switch (editText.getId()) { |
|
|
|
|
|
case R.id.sendAmountEdTxt: |
|
|
|
|
|
if (action) |
|
|
|
|
|
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
else |
|
|
|
|
|
sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher); |
|
|
|
|
|
break; |
|
|
|
|
|
case R.id.receiveAmountEdTxt: |
|
|
|
|
|
if (action) |
|
|
|
|
|
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
else |
|
|
|
|
|
recieveMoneyEditText.removeTextChangedListener(recepientAmountTextWatcher); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class SendAmountTextWatcher implements TextWatcher { |
|
|
|
|
|
|
|
|
private class SendAmountTextWatcher implements TextWatcher { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void afterTextChanged(Editable s) { |
|
|
|
|
|
shouldCaulatedByRecipient = false; |
|
|
|
|
|
updateRecievingAmount(""); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void afterTextChanged(Editable s) { |
|
|
|
|
|
shouldCaulatedByRecipient = false; |
|
|
|
|
|
updateRecievingAmount(""); |
|
|
|
|
|
updateButtonToCalculate(true); |
|
|
|
|
|
showTransferfeeAndExRate(false,"",""); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class RecipientAmountTextWatcher implements TextWatcher { |
|
|
|
|
|
|
|
|
private class RecipientAmountTextWatcher implements TextWatcher { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void afterTextChanged(Editable s) { |
|
|
|
|
|
shouldCaulatedByRecipient = true; |
|
|
|
|
|
updateSendAmount(""); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void afterTextChanged(Editable s) { |
|
|
|
|
|
shouldCaulatedByRecipient = true; |
|
|
|
|
|
updateSendAmount(""); |
|
|
|
|
|
updateButtonToCalculate(true); |
|
|
|
|
|
showTransferfeeAndExRate(false,"",""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |