Browse Source

Exrate send money done

master
preyearegmi 6 years ago
parent
commit
b1873ce117
  1. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGateway.java
  2. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGatewayInterface.java
  3. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2Presenter.java
  4. 9
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2Presenter.java
  5. 102
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGateway.java

@ -14,8 +14,8 @@ public abstract class PrivilegedGateway implements PrivilegedGatewayInterface {
} }
@Override @Override
public String getUserNativeCountryCode() {
return "NP";
public String getSenderCountryId() {
return "118";
} }
@Override @Override

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGatewayInterface.java

@ -8,7 +8,7 @@ public interface PrivilegedGatewayInterface extends BaseGatewayInterface {
String getUserID(); String getUserID();
String getUserNativeCountryCode();
String getSenderCountryId();
String getUserPreferredCurrency(); String getUserPreferredCurrency();
} }

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2Presenter.java

@ -82,7 +82,7 @@ public class ExchangeRateV2Presenter extends BasePresenter implements ExchangeRa
private Observable<CountryPaymentServiceSeedValueModel> getDefaultValue() { private Observable<CountryPaymentServiceSeedValueModel> getDefaultValue() {
return this.gateway.getAllSeedVAlues().flatMap(seedValueList -> { return this.gateway.getAllSeedVAlues().flatMap(seedValueList -> {
String nativeCountryCode = this.gateway.getUserNativeCountryCode();
String nativeCountryCode = this.gateway.getSenderCountryId();
for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) { for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) {
if (seedValueModel.getCountryCode().equalsIgnoreCase(nativeCountryCode)) if (seedValueModel.getCountryCode().equalsIgnoreCase(nativeCountryCode))
return Observable.just(seedValueModel); return Observable.just(seedValueModel);

9
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2Presenter.java

@ -1,11 +1,7 @@
package com.gmeremit.online.gmeremittance_native.sendmoneyV2.presenter; package com.gmeremit.online.gmeremittance_native.sendmoneyV2.presenter;
import android.text.Editable;
import com.gmeremit.online.gmeremittance_native.base.BasePresenter; import com.gmeremit.online.gmeremittance_native.base.BasePresenter;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse; import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationModel;
import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientlisting.RecipientInfoModel; import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientlisting.RecipientInfoModel;
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.gateway.SendMoneyV2Gateway; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.gateway.SendMoneyV2Gateway;
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.amountdetail.AmountDetailRelatedDataModel; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.amountdetail.AmountDetailRelatedDataModel;
@ -16,7 +12,6 @@ import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.payoutmode.Bra
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.payoutmode.PayoutMode; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.payoutmode.PayoutMode;
import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.payoutmode.PayoutModeApiResponse; import com.gmeremit.online.gmeremittance_native.sendmoneyV2.model.payoutmode.PayoutModeApiResponse;
import com.gmeremit.online.gmeremittance_native.utils.Constants; import com.gmeremit.online.gmeremittance_native.utils.Constants;
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -121,12 +116,12 @@ public class SendMoneyV2Presenter extends BasePresenter implements SendMoneyV2Pr
String bankId,String payoutPartnerId,String userID String bankId,String payoutPartnerId,String userID
*/ */
String senderCountryId=gateway.getUserNativeCountryCode();
String senderCountryId=gateway.getSenderCountryId();
String senderCurrency=gateway.getUserPreferredCurrency(); String senderCurrency=gateway.getUserPreferredCurrency();
String paymentMethodId=selectedPaymentModeData.getId(); String paymentMethodId=selectedPaymentModeData.getId();
String calculationPreference=shouldCaulatedByRecipient?Constants.CALC_BY_RECIPEINT:Constants.CALC_BY_SENDER;; String calculationPreference=shouldCaulatedByRecipient?Constants.CALC_BY_RECIPEINT:Constants.CALC_BY_SENDER;;
String recipientCountryName=selectedRecipient.getCountry(); String recipientCountryName=selectedRecipient.getCountry();
String recipientCountryID=selectedRecipient.getCountryCode();
String recipientCountryID=selectedRecipient.getCountryId();
String bankId=(selectedBankData==null)?"":selectedBankData.getId(); String bankId=(selectedBankData==null)?"":selectedBankData.getId();
String paymentPartnerId=selectedPaymentModeData.getPayoutPartner(); String paymentPartnerId=selectedPaymentModeData.getPayoutPartner();

102
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java

@ -34,7 +34,7 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
public class AmountDetailSendMoneyFragment extends BaseFragment implements View.OnClickListener, View.OnKeyListener, AmountDetailExRateCountryListingDialog.ExRateCurrencySelectionListener {
public class AmountDetailSendMoneyFragment extends BaseFragment implements View.OnClickListener, AmountDetailExRateCountryListingDialog.ExRateCurrencySelectionListener, TextView.OnEditorActionListener {
@BindView(R.id.amountDetailContinueButton) @BindView(R.id.amountDetailContinueButton)
Button continueBtn; Button continueBtn;
@ -95,8 +95,8 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
continueBtn.setOnClickListener(this); continueBtn.setOnClickListener(this);
// receiveAmountEdTxt.setOnKeyListener(this);
// sendAmountEdTxt.setOnKeyListener(this);
receiveAmountEdTxt.setOnEditorActionListener(this);
sendAmountEdTxt.setOnEditorActionListener(this);
countrySelectionSpinner.setOnClickListener(this); countrySelectionSpinner.setOnClickListener(this);
} }
@ -104,8 +104,8 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
public void onStop() { public void onStop() {
super.onStop(); super.onStop();
continueBtn.setOnClickListener(null); continueBtn.setOnClickListener(null);
// receiveAmountEdTxt.setOnKeyListener(null);
// sendAmountEdTxt.setOnKeyListener(null);
receiveAmountEdTxt.setOnEditorActionListener(null);
sendAmountEdTxt.setOnEditorActionListener(null);
countrySelectionSpinner.setOnClickListener(null); countrySelectionSpinner.setOnClickListener(null);
} }
@ -153,7 +153,8 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
private void performDefaultAction(Bundle savedInstance) { private void performDefaultAction(Bundle savedInstance) {
shouldCaulatedByRecipient = false; shouldCaulatedByRecipient = false;
compositeDisposable.add( compositeDisposable.add(
((SendMoneyActionListener) getActivity()).getPresenter().getAmountDetailRelatedData().subscribeWith(new AmountDetailRelatedDataObserver()));
((SendMoneyActionListener) getActivity()).getPresenter().getAmountDetailRelatedData().subscribeWith(new AmountDetailRelatedDataObserver())
);
} }
@ -170,34 +171,11 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
} }
} }
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (v.getId()) {
case R.id.sendAmountEdTxt:
if (keyCode == EditorInfo.IME_ACTION_DONE) {
shouldCaulatedByRecipient = false;
if (validateAmountIsNotEmpty(sendAmountEdTxt.getText().toString())) {
}
}
break;
case R.id.receiveAmountEdTxt:
if (keyCode == EditorInfo.IME_ACTION_DONE) {
shouldCaulatedByRecipient = true;
}
break;
}
return false;
}
private void getForex() { private void getForex() {
compositeDisposable.add( compositeDisposable.add(
((SendMoneyActionListener) getActivity()).getPresenter().getForex( ((SendMoneyActionListener) getActivity()).getPresenter().getForex(
receiveAmountEdTxt.getText().toString(), sendAmountEdTxt.getText().toString(), shouldCaulatedByRecipient, "RECIEVERCURRENCY"
receiveAmountEdTxt.getText().toString(), sendAmountEdTxt.getText().toString(), shouldCaulatedByRecipient, amountDetailRelatedData.getDefaultSelectedCurrency().getCurrencyCode()
).doOnSubscribe(d -> showProgressBar(true, "Calculating...")) ).doOnSubscribe(d -> showProgressBar(true, "Calculating..."))
.subscribeWith(new ExchangeRateCalcObserver()) .subscribeWith(new ExchangeRateCalcObserver())
); );
@ -238,41 +216,73 @@ public class AmountDetailSendMoneyFragment extends BaseFragment implements View.
@Override @Override
public void onCurrencySelected(RecipientCurrencyModel selectedCurrency) { public void onCurrencySelected(RecipientCurrencyModel selectedCurrency) {
amountDetailRelatedData.setDefaultSelectedCurrency(selectedCurrency);
if (exRateCountryListingDialog != null) if (exRateCountryListingDialog != null)
exRateCountryListingDialog.dismiss(); exRateCountryListingDialog.dismiss();
exRateCountryListingDialog = null; exRateCountryListingDialog = null;
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(sendAmountEdTxt.getText().toString()))
getForex();
}
return true;
case R.id.receiveAmountEdTxt:
if (actionId == EditorInfo.IME_ACTION_DONE) {
hideKeyBoard();
shouldCaulatedByRecipient = true;
if (validateAmountIsNotEmpty(receiveAmountEdTxt.getText().toString()))
getForex();
}
return true;
}
return false;
} }
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> { public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> {
@Override @Override
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) {
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData();
String transferAmount = data.getScCharge();
String exRate = data.getExRateDisplay();
String recipientAmount = data.getpAmt();
String sendAmount = data.getCollAmt();
String sendingCurrency = data.getCollCurr();
String transferDisplay = " - " + transferAmount + " " + sendingCurrency + " (Transfer Fee Included)";
String exRateDisplay = " " + exRate + " (Current Exchange Rate)";
showTransferfeeAndExRate(transferDisplay, exRateDisplay);
showSendAndRecieveAmount(sendAmount, recipientAmount);
} else
showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
if(isUIReady()) {
showProgressBar(false, "");
if (exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData();
String transferAmount = data.getScCharge();
String exRate = data.getExRateDisplay();
String recipientAmount = data.getpAmt();
String sendAmount = data.getCollAmt();
String sendingCurrency = data.getCollCurr();
String transferDisplay = " - " + transferAmount + " " + sendingCurrency + " (Transfer Fee Included)";
String exRateDisplay = " " + exRate + " (Current Exchange Rate)";
showTransferfeeAndExRate(transferDisplay, exRateDisplay);
showSendAndRecieveAmount(sendAmount, recipientAmount);
} else
showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
}
} }
@Override @Override
public void onFailed(String message) { public void onFailed(String message) {
showProgressBar(false,"");
showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
} }
@Override @Override
protected void onConnectionNotEstablished(String message) { protected void onConnectionNotEstablished(String message) {
showProgressBar(false,"");
showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null);
} }
} }

Loading…
Cancel
Save