Preyea Regmi
5 years ago
60 changed files with 105 additions and 1647 deletions
-
34app/src/main/AndroidManifest.xml
-
9app/src/main/java/com/gmeremit/online/gmeremittance_native/agentsV2/gateway/AgentListV2Gateway.java
-
1app/src/main/java/com/gmeremit/online/gmeremittance_native/agentsV2/model/AgentsListApiResponse.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/agentsV2/presenter/AgentListV2PresenterInterface.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/CountryListingRvAdapter.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/CountrySelectionListener.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/customwidgets/exchangecountrylistingdialog/ExchangeRateCurrencyListingDialog.java
-
115app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/gateway/ExchangeRateV2Gateway.java
-
28app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2InteractorInterface.java
-
269app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2Presenter.java
-
36app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2PresenterInterface.java
-
623app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java
-
10app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/adapter/PaymentModeRvAdapter.java
-
55app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/gateway/ExchangeRateGateway.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/PaymentModeMapper.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/CountryPaymentService.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/CountryPaymentServiceSeedValueApiResponse.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/CountryPaymentServiceSeedValueModel.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/ExchangeCalculationApiResponse.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/ExchangeCalculationModel.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/GenericApiResponseModel.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/PaymentMode.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/model/datav2/PaymentServiceApiResponse.java
-
9app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/presenter/ExchangeRateInteractorInterface.java
-
15app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/presenter/ExchangeRatePresenter.java
-
7app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/presenter/ExchangeRatePresenterInterface.java
-
17app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/view/ExchangeRateActivity.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/view/PaymentModeViewHolder.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/exrate/view/SelectedRedBorderDecoration.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/model/recipientaddeditV3/countryservice/ServiceTypeModel.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/gateway/resend/ReSendMoneyV2Gateway.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2InteractorInterface.java
-
5app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2Presenter.java
-
9app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2PresenterInterface.java
-
9app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/view/amountdetail/ResendMoneyAmountDetailFragment.java
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/adapter/SendMoneyPayoutModeRvAdapter.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/gateway/SendMoneyV2Gateway.java
-
6app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyTransactionCompleteV2InteractorInterface.java
-
12app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyTransactionCompleteV2PresenterInterface.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2InteractorInterface.java
-
5app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2Presenter.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2PresenterInterface.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailExRateCountryListingDialog.java
-
10app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/amountdetail/AmountDetailSendMoneyFragment.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeSendMoneyFragment.java
-
3app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/LanguageSelectionListingDialog.java
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/socials/view/SocialPrivateWallActivity.java
-
6app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/adapter/PayoutModeSelectionRVAdapter.java
-
6app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/gateway/SplashScreenGateway.java
-
6app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenInteractorInterface.java
-
295app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java
-
33app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java
-
45app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java
-
4app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/ApiEndpoints.java
-
2app/src/main/res/layout/activity_bank_account_validation_v2.xml
-
2app/src/main/res/layout/activity_exchange_method_v2.xml
-
2app/src/main/res/layout/activity_withdraw_v2.xml
-
2app/src/main/res/layout/fragment_amount_detail_resend_money_v2.xml
-
2app/src/main/res/layout/fragment_amount_detail_send_money_v2.xml
@ -1,6 +1,6 @@ |
|||
package com.gmeremit.online.gmeremittance_native.customwidgets.exchangecountrylistingdialog; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exrate.model.datav2.CountryPaymentService; |
|||
|
|||
public interface CountrySelectionListener { |
|||
void onCountrySelected(CountryPaymentService countryPaymentService); |
|||
|
@ -1,115 +0,0 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.gateway; |
|||
|
|||
import android.util.Log; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueApiResponse; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRateV2InteractorInterface; |
|||
import com.gmeremit.online.gmeremittance_native.utils.https.HttpClientV2; |
|||
import com.google.gson.Gson; |
|||
import com.google.gson.GsonBuilder; |
|||
import com.google.gson.JsonObject; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import io.reactivex.Observable; |
|||
|
|||
public class ExchangeRateV2Gateway extends PrivilegedGateway implements ExchangeRateV2InteractorInterface.ExchangeRateV2GatewayInterface { |
|||
|
|||
|
|||
|
|||
@Override |
|||
public Observable<PaymentServiceApiResponse> getPaymentServiceInfoFromServer(String auth) { |
|||
return HttpClientV2.getInstance().getPaymentServiceV2(auth); |
|||
|
|||
} |
|||
|
|||
|
|||
@Override |
|||
public Observable<List<CountryPaymentServiceSeedValueModel>> getAllSeedVAlues() { |
|||
|
|||
|
|||
/** |
|||
* azerbaijan 1,000 AZ USD |
|||
Bangladesh 100,000 BD USD |
|||
Belarus 1,000 BY USD |
|||
Cambodia 500 KH USD |
|||
Georgia 1,000 GE USD |
|||
India 100,000 IN INR |
|||
Indonesia 15,000,000 ID IDR |
|||
Kazakhstan 1,000 KZ USD |
|||
Kyrgyzstan 1,000 KG USD |
|||
Malaysia 10,000 MY MYR |
|||
Moldova 1,000 MD USD |
|||
Mongolia(USD) 1,000 MN USD |
|||
Mongolia(MNT) 2,000,000 MN MNT |
|||
Myanmar 1,500,000 MM MMK |
|||
Nepal 100,000 NP NPR |
|||
Pakistan 100,000 PK PKR |
|||
Philippines 500 PH PHP |
|||
Russian Federation 1,000 RU USD |
|||
Singapore 2,000 SG SGD |
|||
Sri Lanka(LKR) 100,000 LK LKR |
|||
Sri Lanka(USD) 1,000 LK USD |
|||
Tajikistan 1,000 TJ USD |
|||
Thailand(THB) 30,000 TH THB |
|||
Uzbekistan 1,000 UZ USD |
|||
Vietnam(VND) 50,000,000 VN VND |
|||
Vietnam(USD) 2,000 VN USD |
|||
*/ |
|||
List<CountryPaymentServiceSeedValueModel> seedData=new ArrayList<>(); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("AZ","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("BD","100000","BDT")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("BY","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("KH","500","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("GE","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("IN","100000","INR")); |
|||
// seedData.add(new CountryPaymentServiceSeedValueModel("ID","15000000","IDR")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("KZ","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("KG","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("MY","10000","MYR")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("MD","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("MN","2000000","MNT")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("MN","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("MM","1500000","MMK")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("NP","100000","NPR")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("PK","100000","PKR")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("PH","500","PHP")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("RU","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("SG","2000","SGD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("LK","100000","LKR")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("LK","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("TJ","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("TH","30000","THB")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("UZ","1000","USD")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("VN","50000000","VND")); |
|||
seedData.add(new CountryPaymentServiceSeedValueModel("VN","2000","USD")); |
|||
return Observable.just(seedData); |
|||
} |
|||
|
|||
@Override |
|||
public Observable<ExchangeCalculationApiResponse> sendDataForForexCalculation(String auth,String senderCountryId, String senderCurrency, String recieverCurrency, |
|||
String senderAmount, String recieverAmount, String paymentMethodId, |
|||
String calculationPreference, String recipientCountryName,String recieverCountryId) { |
|||
|
|||
JsonObject jsonObject=new JsonObject(); |
|||
jsonObject.addProperty("sCountry",senderCountryId); |
|||
jsonObject.addProperty("sCurrency",senderCurrency); |
|||
jsonObject.addProperty("pCurrency",recieverCurrency); |
|||
jsonObject.addProperty("calcBy",calculationPreference); |
|||
jsonObject.addProperty("cAmount",senderAmount); |
|||
jsonObject.addProperty("pAmount",recieverAmount); |
|||
jsonObject.addProperty("serviceType",paymentMethodId); |
|||
jsonObject.addProperty("pCountry",recieverCountryId); |
|||
jsonObject.addProperty("pCountryName",recipientCountryName); |
|||
|
|||
|
|||
return HttpClientV2.getInstance().calculateExchangeRateV2(auth,jsonObject); |
|||
} |
|||
|
|||
|
|||
} |
@ -1,28 +0,0 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.base.BaseGatewayInterface; |
|||
import com.gmeremit.online.gmeremittance_native.base.BaseInteractorInterface; |
|||
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGatewayInterface; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.ExchangeCalculationApiResponse; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse; |
|||
|
|||
import java.util.List; |
|||
|
|||
import io.reactivex.Observable; |
|||
|
|||
public interface ExchangeRateV2InteractorInterface extends BaseInteractorInterface { |
|||
|
|||
|
|||
interface ExchangeRateV2GatewayInterface extends PrivilegedGatewayInterface |
|||
{ |
|||
//Change to observable rxjava |
|||
Observable<PaymentServiceApiResponse> getPaymentServiceInfoFromServer(String auth); |
|||
Observable<List<CountryPaymentServiceSeedValueModel>> getAllSeedVAlues(); |
|||
|
|||
Observable<ExchangeCalculationApiResponse> sendDataForForexCalculation(String auth,String senderCountryId, String senderCurrency, String recieverCurrency, |
|||
String senderAmount, String recieverAmount, String paymentMethodId, |
|||
String calculationPreference, String recipientCountryName,String recieverCountryId); |
|||
} |
|||
} |
@ -1,269 +0,0 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.GmeApplication; |
|||
import com.gmeremit.online.gmeremittance_native.R; |
|||
import com.gmeremit.online.gmeremittance_native.base.BasePresenter; |
|||
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.gateway.ExchangeRateV2Gateway; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel; |
|||
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.exchange_rate.model.datav2.PaymentMode; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse; |
|||
import com.gmeremit.online.gmeremittance_native.utils.Constants; |
|||
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|||
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponse; |
|||
|
|||
import io.reactivex.Observable; |
|||
import io.reactivex.android.schedulers.AndroidSchedulers; |
|||
import io.reactivex.disposables.CompositeDisposable; |
|||
import io.reactivex.observers.DisposableObserver; |
|||
import io.reactivex.schedulers.Schedulers; |
|||
|
|||
public class ExchangeRateV2Presenter extends BasePresenter implements ExchangeRateV2PresenterInterface, ExchangeRateV2InteractorInterface { |
|||
|
|||
private final ExchangeRateV2ContractInterface view; |
|||
private final ExchangeRateV2GatewayInterface gateway; |
|||
private final CompositeDisposable compositeDisposables; |
|||
|
|||
public ExchangeRateV2Presenter(ExchangeRateV2ContractInterface view,ExchangeRateV2GatewayInterface gateway) { |
|||
this.view = view; |
|||
this.gateway = gateway; |
|||
this.compositeDisposables = new CompositeDisposable(); |
|||
} |
|||
|
|||
@Override |
|||
public void getAllData() { |
|||
compositeDisposables.add( |
|||
Observable.zip(getPaymentServiceInfo(), getDefaultValue(), PaymentServiceData::new) |
|||
.doOnSubscribe(disposable -> this.view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) |
|||
.observeOn(AndroidSchedulers.mainThread()) |
|||
.doFinally(() -> this.view.showProgressBar(false, "")) |
|||
.subscribeWith(new PaymentServiceDataObserver()) |
|||
); |
|||
} |
|||
|
|||
@Override |
|||
public void getForex(CountryPaymentService selectedCountryPaymentService, PaymentMode selectedPaymentMode, String recipientAmount, String sendAmount, boolean shouldCalculatedByRecipient) { |
|||
String calculateFlag=shouldCalculatedByRecipient?Constants.CALC_BY_RECIPEINT:Constants.CALC_BY_SENDER; |
|||
if(!validateAmount(recipientAmount)) |
|||
return; |
|||
if(!validateAmount(sendAmount)) |
|||
return; |
|||
if(selectedCountryPaymentService==null) |
|||
{ |
|||
view.showToastMessage(getStringfromStringId(R.string.no_currency_selected_error)); |
|||
return; |
|||
} |
|||
String sendCountryDefault="118"; |
|||
|
|||
String auth = "Basic " + Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + GmeApplication.getAppRelatedMetaData(view.getContext()).getDeviceId()); |
|||
|
|||
compositeDisposables.add( |
|||
this.gateway.sendDataForForexCalculation(auth, |
|||
sendCountryDefault, |
|||
gateway.getUserPreferredCurrency(),selectedCountryPaymentService.getCurrency(), |
|||
Utils.removeCommaFromAmount(sendAmount),Utils.removeCommaFromAmount(recipientAmount),selectedPaymentMode.getId(),calculateFlag,selectedCountryPaymentService.getCountry(), |
|||
selectedCountryPaymentService.getCountryId()) |
|||
.doOnSubscribe(disposable -> this.view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text))) |
|||
.doOnError((err) -> this.view.showProgressBar(false, "")) |
|||
.subscribeOn(Schedulers.io()) |
|||
.observeOn(AndroidSchedulers.mainThread()) |
|||
.doFinally(()->this.view.showProgressBar(false, "")) |
|||
.subscribeWith(new ExchangeRateCalcObserver()) |
|||
); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void getDefaultReceivingAmountForSelectedCurrency(CountryPaymentService countryPaymentService) { |
|||
String nativeCountryCode = countryPaymentService.getCountryCode(); |
|||
String preferredCurrency= countryPaymentService.getCurrency(); |
|||
compositeDisposables.add( |
|||
this.gateway.getAllSeedVAlues().flatMap(seedValueList -> { |
|||
for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) { |
|||
if (seedValueModel.getCountryCode().equalsIgnoreCase(nativeCountryCode)&&seedValueModel.getCurrency().equalsIgnoreCase(preferredCurrency)) |
|||
return Observable.just(seedValueModel); |
|||
} |
|||
return Observable.just(new CountryPaymentServiceSeedValueModel(null, null, null)); |
|||
}).subscribeWith(new DefaultRecievingAmountObserver())); |
|||
} |
|||
|
|||
@Override |
|||
public void onViewDestroyed() { |
|||
super.onViewDestroyed(); |
|||
if (compositeDisposables != null && !compositeDisposables.isDisposed()) |
|||
compositeDisposables.dispose(); |
|||
} |
|||
|
|||
private boolean validateAmount(String amount) { |
|||
return true; |
|||
} |
|||
|
|||
|
|||
private Observable<CountryPaymentServiceSeedValueModel> getDefaultValue() { |
|||
|
|||
return this.gateway.getAllSeedVAlues().flatMap(seedValueList -> { |
|||
String nativeCountryCode = this.gateway.getUserNativeCountryCode(); |
|||
for (CountryPaymentServiceSeedValueModel seedValueModel : seedValueList) { |
|||
if (seedValueModel.getCountryCode().equalsIgnoreCase(nativeCountryCode)) |
|||
return Observable.just(seedValueModel); |
|||
} |
|||
return Observable.just(new CountryPaymentServiceSeedValueModel(null, null, null)); |
|||
}); |
|||
|
|||
} |
|||
|
|||
private Observable<PaymentServiceApiResponse> getPaymentServiceInfo() { |
|||
String auth = "Basic " + Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + GmeApplication.getAppRelatedMetaData(view.getContext()).getDeviceId()); |
|||
return this.gateway.getPaymentServiceInfoFromServer(auth).subscribeOn(Schedulers.io()); |
|||
} |
|||
|
|||
|
|||
public class PaymentServiceDataObserver extends GenericApiObserverResponse<PaymentServiceData> { |
|||
|
|||
@Override |
|||
protected void onSuccess(PaymentServiceData paymentServiceApiResponse) { |
|||
if(paymentServiceApiResponse.paymentServiceApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|||
CountryPaymentServiceSeedValueModel seedValueModel = paymentServiceApiResponse.getCountryPaymentServiceSeedValueModel(); |
|||
CountryPaymentService defaultSelectedCountryService ; |
|||
try { |
|||
defaultSelectedCountryService = paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServiceFromCountryCodeAndCurrency(seedValueModel.getCountryCode(), seedValueModel.getCurrency()); |
|||
} |
|||
catch(Exception e) |
|||
{ |
|||
defaultSelectedCountryService=null; |
|||
} |
|||
|
|||
if (defaultSelectedCountryService == null || defaultSelectedCountryService.getCountryCode() == null || defaultSelectedCountryService.getCountry() == null || defaultSelectedCountryService.getCurrency() == null) { |
|||
|
|||
view.showCountryServiceDataForNonListedNativeCountry(paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServices(),Constants.DEFAULT_EXCHANGE_SEND_AMOUNT); |
|||
} else { |
|||
view.showCountryServiceDataForListedNativeCountry(paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServices(),defaultSelectedCountryService,seedValueModel.getRecipientSeedValue()); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
view.showPopUpMessage(paymentServiceApiResponse.paymentServiceApiResponse.getMessage(), CustomAlertDialog.AlertType.FAILED,null); |
|||
view.clearCurrencyData(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onFailed(String message) { |
|||
|
|||
view.clearCurrencyData(); |
|||
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|||
} |
|||
|
|||
@Override |
|||
protected void onConnectionNotEstablished(String message) { |
|||
view.clearCurrencyData(); |
|||
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.logout()); |
|||
} |
|||
} |
|||
|
|||
public class PaymentServiceData { |
|||
private PaymentServiceApiResponse paymentServiceApiResponse; |
|||
private CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel; |
|||
|
|||
public PaymentServiceData(PaymentServiceApiResponse paymentServiceApiResponse, CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel) { |
|||
this.paymentServiceApiResponse = paymentServiceApiResponse; |
|||
this.countryPaymentServiceSeedValueModel = countryPaymentServiceSeedValueModel; |
|||
} |
|||
|
|||
public PaymentServiceApiResponse getPaymentServiceApiResponse() { |
|||
return paymentServiceApiResponse; |
|||
} |
|||
|
|||
public void setPaymentServiceApiResponse(PaymentServiceApiResponse paymentServiceApiResponse) { |
|||
this.paymentServiceApiResponse = paymentServiceApiResponse; |
|||
} |
|||
|
|||
public CountryPaymentServiceSeedValueModel getCountryPaymentServiceSeedValueModel() { |
|||
return countryPaymentServiceSeedValueModel; |
|||
} |
|||
|
|||
public void setCountryPaymentServiceSeedValueModel(CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel) { |
|||
this.countryPaymentServiceSeedValueModel = countryPaymentServiceSeedValueModel; |
|||
} |
|||
} |
|||
|
|||
public class ExchangeRateCalcObserver extends GenericApiObserverResponse<ExchangeCalculationApiResponse> |
|||
{ |
|||
|
|||
@Override |
|||
protected void onSuccess(ExchangeCalculationApiResponse exchangeCalculationApiResponse) { |
|||
if(exchangeCalculationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { |
|||
ExchangeCalculationModel data = exchangeCalculationApiResponse.getData(); |
|||
String transferAmount = Utils.formatCurrency(data.getScCharge()); |
|||
String exRate = data.getExRateDisplay(); |
|||
String recipientAmount = data.getpAmt(); |
|||
String sendAmount = data.getCollAmt(); |
|||
String sendingCurrency = data.getCollCurr(); |
|||
|
|||
String transferDisplay = " - " + transferAmount +" "+ sendingCurrency + " ("+getStringfromStringId(R.string.transfer_fee_included_text)+")"; |
|||
String exRateDisplay = " " + exRate + " ("+getStringfromStringId(R.string.current_exchange_rate_text)+")"; |
|||
|
|||
view.updateExchangeRates(recipientAmount, sendAmount, transferDisplay, exRateDisplay); |
|||
} |
|||
else { |
|||
view.clearExrateAndServiceCharge(); |
|||
view.showPopUpMessage(exchangeCalculationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onFailed(String message) { |
|||
view.clearExrateAndServiceCharge(); |
|||
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|||
} |
|||
|
|||
@Override |
|||
protected void onConnectionNotEstablished(String message) { |
|||
view.clearExrateAndServiceCharge(); |
|||
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.logout()); |
|||
|
|||
} |
|||
} |
|||
|
|||
public class DefaultRecievingAmountObserver extends DisposableObserver<CountryPaymentServiceSeedValueModel> |
|||
{ |
|||
|
|||
@Override |
|||
public void onNext(CountryPaymentServiceSeedValueModel countryPaymentServiceSeedValueModel) { |
|||
String receivingAmount=countryPaymentServiceSeedValueModel.getRecipientSeedValue(); |
|||
if(receivingAmount!=null) |
|||
view.updateReceivingAmountAndFetchExchangeRate(Utils.formatCurrency(receivingAmount)); |
|||
else |
|||
view.fallbackToSendingAmountAndFetchExchangeRate(Utils.formatCurrency(Constants.DEFAULT_EXCHANGE_SEND_AMOUNT)); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void onError(Throwable e) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void onComplete() { |
|||
|
|||
} |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.base.BaseContractInterface; |
|||
import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ExchangeRateV2PresenterInterface extends BasePresenterInterface { |
|||
|
|||
void getAllData(); |
|||
|
|||
void getForex(CountryPaymentService selectedCountryPaymentService, PaymentMode selectedPaymentMode, String recieveAmount, String sendMoneyEditTextText, boolean shouldCaulatedByRecipient); |
|||
|
|||
void getDefaultReceivingAmountForSelectedCurrency(CountryPaymentService countryPaymentService); |
|||
|
|||
interface ExchangeRateV2ContractInterface extends BaseContractInterface |
|||
{ |
|||
@Deprecated |
|||
void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryService,String recepientSeedValue); |
|||
|
|||
void showCountryServiceDataForListedNativeCountry(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryService, String recepientSeedValue); |
|||
|
|||
void showCountryServiceDataForNonListedNativeCountry(List<CountryPaymentService> countryPaymentServiceList, String recepientSeedValue); |
|||
|
|||
void updateExchangeRates(String recipientAmount, String sendAmount, String transferDisplay, String exRateDisplay); |
|||
|
|||
void clearCurrencyData(); |
|||
|
|||
void updateReceivingAmountAndFetchExchangeRate(String amount); |
|||
void fallbackToSendingAmountAndFetchExchangeRate(String amount); |
|||
|
|||
void clearExrateAndServiceCharge(); |
|||
} |
|||
} |
@ -1,623 +0,0 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.view; |
|||
|
|||
import android.graphics.Rect; |
|||
import android.os.Bundle; |
|||
import android.support.v4.view.GestureDetectorCompat; |
|||
import android.support.v4.view.ViewCompat; |
|||
import android.support.v7.widget.DefaultItemAnimator; |
|||
import android.support.v7.widget.RecyclerView; |
|||
import android.text.Editable; |
|||
import android.text.TextWatcher; |
|||
import android.view.GestureDetector; |
|||
import android.view.KeyEvent; |
|||
import android.view.MotionEvent; |
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
import android.view.animation.AccelerateDecelerateInterpolator; |
|||
import android.view.animation.Interpolator; |
|||
import android.view.inputmethod.EditorInfo; |
|||
import android.widget.Button; |
|||
import android.widget.EditText; |
|||
import android.widget.ImageView; |
|||
import android.widget.ScrollView; |
|||
import android.widget.TextView; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.R; |
|||
import com.gmeremit.online.gmeremittance_native.base.BaseActivity; |
|||
import com.gmeremit.online.gmeremittance_native.customwidgets.CurrencyFormatterTextWatcher; |
|||
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; |
|||
import com.gmeremit.online.gmeremittance_native.customwidgets.exchangecountrylistingdialog.CountryFlagMapper; |
|||
import com.gmeremit.online.gmeremittance_native.customwidgets.exchangecountrylistingdialog.ExchangeRateCurrencyListingDialog; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.adapter.PaymentModeRvAdapter; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.gateway.ExchangeRateV2Gateway; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRateV2Presenter; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.presenter.ExchangeRateV2PresenterInterface; |
|||
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|||
|
|||
import java.util.List; |
|||
|
|||
import butterknife.BindView; |
|||
import butterknife.ButterKnife; |
|||
|
|||
public class ExchangeMethodV2Activity extends BaseActivity implements PaymentModeRvAdapter.OnPaymentModeSelectionListener, ExchangeRateCurrencyListingDialog.CountrySelectionListener, View.OnClickListener, ExchangeRateV2PresenterInterface.ExchangeRateV2ContractInterface, TextView.OnEditorActionListener { |
|||
|
|||
@BindView(R.id.sendAmountEdTxt) |
|||
EditText sendMoneyEditText; |
|||
|
|||
@BindView(R.id.receiveAmountEdTxt) |
|||
EditText recieveMoneyEditText; |
|||
|
|||
@BindView(R.id.paymentModeRV) |
|||
RecyclerView paymentModeRv; |
|||
|
|||
@BindView(R.id.toolbar_title) |
|||
GmeTextView toolbarTitle; |
|||
|
|||
@BindView(R.id.countrySelectionSpinner) |
|||
View countrySelectionSpinner; |
|||
|
|||
@BindView(R.id.recepientFlagImageView) |
|||
ImageView recepientFlagImageView; |
|||
|
|||
@BindView(R.id.recepientCurrencyTextView) |
|||
TextView recepientCurrencyTextView; |
|||
|
|||
@BindView(R.id.transferFeeTxtView) |
|||
TextView transferFeeTxtView; |
|||
|
|||
@BindView(R.id.exchangeRateTxtView) |
|||
TextView exchangeRateTxtView; |
|||
|
|||
@BindView(R.id.paymentModeViewContainer) |
|||
ViewGroup paymentModeViewContainer; |
|||
|
|||
@BindView(R.id.iv_back) |
|||
View iv_back; |
|||
|
|||
@BindView(R.id.iv_cancel) |
|||
View iv_cancel; |
|||
|
|||
@BindView(R.id.rootView) |
|||
ScrollView rootView; |
|||
|
|||
@BindView(R.id.receiveMoneyViewContainer) |
|||
View receiveMoneyViewContainer; |
|||
|
|||
@BindView(R.id.sendMoneyViewContainer) |
|||
View sendMoneyViewContainer; |
|||
|
|||
@BindView(R.id.generic_toolbar) |
|||
View toolbar; |
|||
|
|||
@BindView(R.id.exRateCalculateButton) |
|||
Button exRateCalculateButton; |
|||
|
|||
|
|||
private PaymentModeRvAdapter paymentModeRvAdapter; |
|||
private PaymentMode selectedPaymentMode; |
|||
private List<CountryPaymentService> paymentServiceList; |
|||
private ExchangeRateCurrencyListingDialog countryListingDialog; |
|||
private CountryPaymentService selectedCountryPaymentService; |
|||
private ExchangeRateV2PresenterInterface presenter; |
|||
private boolean shouldCaulatedByRecipient; |
|||
private SendAmountTextWatcher sendAmountTextWatcher; |
|||
private RecipientAmountTextWatcher recepientAmountTextWatcher; |
|||
private CurrencyFormatterTextWatcher sendCurrencyFormatterTextWatcher; |
|||
private CurrencyFormatterTextWatcher recepientCurrencyFormatterTextWatcher; |
|||
private Interpolator interpolator; |
|||
private AmountChangeAndFocusOutDetector myViewGestureDetector; |
|||
private GestureDetectorCompat gestureDetector; |
|||
private SendMoneyFocusChangeListener sendMoneyFocusChangeListener; |
|||
|
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
this.sendAmountTextWatcher = new SendAmountTextWatcher(); |
|||
this.recepientAmountTextWatcher = new RecipientAmountTextWatcher(); |
|||
setContentView(R.layout.activity_exchange_method_v2); |
|||
ButterKnife.bind(this); |
|||
init(); |
|||
performDefaultAction(savedInstanceState); |
|||
|
|||
} |
|||
|
|||
private void init() { |
|||
|
|||
setupRv(); |
|||
iv_cancel.setVisibility(View.INVISIBLE); |
|||
this.interpolator = new AccelerateDecelerateInterpolator(); |
|||
this.presenter = new ExchangeRateV2Presenter(this,new ExchangeRateV2Gateway()); |
|||
registerTextWatchers(true); |
|||
myViewGestureDetector = new AmountChangeAndFocusOutDetector(); |
|||
gestureDetector = new GestureDetectorCompat(this, myViewGestureDetector); |
|||
|
|||
sendMoneyFocusChangeListener=new SendMoneyFocusChangeListener(); |
|||
} |
|||
|
|||
private void performDefaultAction(Bundle savedInstanceState) { |
|||
toolbarTitle.setText(getString(R.string.todays_rate_title_text)); |
|||
this.presenter.getAllData(); |
|||
} |
|||
|
|||
|
|||
private void showPaymentService(boolean action, List<PaymentMode> paymentModeList) { |
|||
if (paymentModeRvAdapter != null && action && paymentModeList.size() > 0) { |
|||
if (paymentModeViewContainer.getVisibility() != View.VISIBLE) |
|||
paymentModeViewContainer.setVisibility(View.VISIBLE); |
|||
paymentModeRvAdapter.setData(paymentModeList); |
|||
paymentModeRvAdapter.setSelectedItem(0); |
|||
} |
|||
} |
|||
|
|||
private void setupRv() { |
|||
paymentModeRvAdapter = new PaymentModeRvAdapter(this); |
|||
paymentModeRv.setAdapter(paymentModeRvAdapter); |
|||
paymentModeRv.addItemDecoration(new SelectedRedBorderDecoration(this)); |
|||
paymentModeRv.setItemAnimator(new DefaultItemAnimator()); |
|||
|
|||
} |
|||
|
|||
private void showCountryListinDialog() { |
|||
if (countryListingDialog == null) |
|||
countryListingDialog = new ExchangeRateCurrencyListingDialog(); |
|||
countryListingDialog.setCountryPaymentData(paymentServiceList); |
|||
countryListingDialog.setListener(this); |
|||
if (!countryListingDialog.isAdded()) |
|||
countryListingDialog.show(getSupportFragmentManager(), "GenericTextListingDialog"); |
|||
} |
|||
|
|||
@Override |
|||
protected void onStart() { |
|||
super.onStart(); |
|||
countrySelectionSpinner.setOnClickListener(this); |
|||
exRateCalculateButton.setOnClickListener(this); |
|||
iv_back.setOnClickListener(this); |
|||
recieveMoneyEditText.setOnEditorActionListener(this); |
|||
sendMoneyEditText.setOnEditorActionListener(this); |
|||
sendMoneyEditText.setOnFocusChangeListener(sendMoneyFocusChangeListener); |
|||
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
protected void onStop() { |
|||
super.onStop(); |
|||
countrySelectionSpinner.setOnClickListener(null); |
|||
exRateCalculateButton.setOnClickListener(null); |
|||
iv_back.setOnClickListener(null); |
|||
recieveMoneyEditText.setOnEditorActionListener(null); |
|||
sendMoneyEditText.setOnEditorActionListener(null); |
|||
sendMoneyEditText.setOnFocusChangeListener(null); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void onPaymentModeSelected(PaymentMode selectedData) { |
|||
this.selectedPaymentMode = selectedData; |
|||
prepareToGetForex(); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void onCountrySelected(CountryPaymentService countryPaymentService) { |
|||
if (this.countryListingDialog != null) { |
|||
this.countryListingDialog.hideKeyboard(); |
|||
this.countryListingDialog.dismiss(); |
|||
} |
|||
if(this.selectedCountryPaymentService!=null&&(this.selectedCountryPaymentService.getCurrency().equalsIgnoreCase(countryPaymentService.getCurrency()))&&(this.selectedCountryPaymentService.getCountryCode().equalsIgnoreCase(countryPaymentService.getCountryCode()))) |
|||
return; |
|||
|
|||
this.selectedCountryPaymentService = countryPaymentService; |
|||
showSelectedRecipient(countryPaymentService.getCountryCode(), countryPaymentService.getCurrency()); |
|||
this.presenter.getDefaultReceivingAmountForSelectedCurrency(countryPaymentService); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void updateReceivingAmountAndFetchExchangeRate(String amount) { |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); |
|||
recieveMoneyEditText.setText(amount); |
|||
shouldCaulatedByRecipient = true; |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); |
|||
showPaymentService(true, this.selectedCountryPaymentService.getServiceAvailable()); |
|||
} |
|||
|
|||
@Override |
|||
public void fallbackToSendingAmountAndFetchExchangeRate(String s) { |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, false); |
|||
recieveMoneyEditText.setText(""); |
|||
sendMoneyEditText.setText(s); |
|||
shouldCaulatedByRecipient = false; |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, true); |
|||
showPaymentService(true, this.selectedCountryPaymentService.getServiceAvailable()); |
|||
} |
|||
|
|||
@Override |
|||
public void clearExrateAndServiceCharge() { |
|||
transferFeeTxtView.setText(""); |
|||
exchangeRateTxtView.setText(""); |
|||
} |
|||
|
|||
private void showSelectedRecipient(String selectedCountryCode, String selectedCountryCurrency) { |
|||
int flagResId = CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode); |
|||
if (flagResId != -1) |
|||
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode)); |
|||
if (selectedCountryCurrency != null) |
|||
this.recepientCurrencyTextView.setText(selectedCountryCurrency); |
|||
} |
|||
|
|||
@Override |
|||
public void clearCurrencyData() { |
|||
this.recepientFlagImageView.setBackgroundResource(0); |
|||
this.recepientCurrencyTextView.setText("---"); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public boolean dispatchTouchEvent(MotionEvent ev) { |
|||
gestureDetector.onTouchEvent(ev); |
|||
return super.dispatchTouchEvent(ev); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void onClick(View v) { |
|||
switch (v.getId()) { |
|||
case R.id.countrySelectionSpinner: |
|||
showCountryListinDialog(); |
|||
break; |
|||
case R.id.exRateCalculateButton: |
|||
prepareToGetForex(); |
|||
break; |
|||
|
|||
case R.id.iv_back: |
|||
onBackPressed(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
|||
switch (v.getId()) { |
|||
case R.id.sendAmountEdTxt: |
|||
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|||
shouldCaulatedByRecipient = false; |
|||
if (sendMoneyEditText.getText().toString().length() > 0) |
|||
prepareToGetForex(); |
|||
else |
|||
showToastMessage(getString(R.string.sending_amount_error)); |
|||
} |
|||
return true; |
|||
|
|||
case R.id.receiveAmountEdTxt: |
|||
if (actionId == EditorInfo.IME_ACTION_DONE) { |
|||
shouldCaulatedByRecipient = true; |
|||
if (recieveMoneyEditText.getText().toString().length() > 0) |
|||
prepareToGetForex(); |
|||
else |
|||
showToastMessage(getString(R.string.receiving_amount_error)); |
|||
} |
|||
return true; |
|||
|
|||
} |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
protected void onDestroy() { |
|||
super.onDestroy(); |
|||
presenter.onViewDestroyed(); |
|||
registerTextWatchers(false); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryPaymentService, String seedValue) { |
|||
if (defaultCountryPaymentService != null) { |
|||
if (seedValue != null) { |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, false); |
|||
this.recieveMoneyEditText.setText(Utils.formatCurrency(seedValue)); |
|||
shouldCaulatedByRecipient = true; |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, true); |
|||
} |
|||
this.selectedCountryPaymentService = defaultCountryPaymentService; |
|||
this.selectedPaymentMode = defaultCountryPaymentService.getServiceAvailable().get(0); |
|||
showSelectedRecipient(defaultCountryPaymentService.getCountryCode(), defaultCountryPaymentService.getCurrency()); |
|||
showPaymentService(true, defaultCountryPaymentService.getServiceAvailable()); |
|||
|
|||
|
|||
} else { |
|||
if (seedValue != null) { |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, false); |
|||
this.sendMoneyEditText.setText(Utils.formatCurrency(seedValue)); |
|||
shouldCaulatedByRecipient = false; |
|||
recieveMoneyEditText.setText(""); |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, true); |
|||
} |
|||
|
|||
//We are taking first item as default as we don't have any default item enlisted |
|||
CountryPaymentService firstSelectedItem = countryPaymentServiceList.get(0); |
|||
for (CountryPaymentService item : countryPaymentServiceList) { |
|||
if (item.getCountryCode().equalsIgnoreCase("NP")) { |
|||
firstSelectedItem = item; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
this.selectedCountryPaymentService = firstSelectedItem; |
|||
this.selectedPaymentMode = firstSelectedItem.getServiceAvailable().get(0); |
|||
showSelectedRecipient(firstSelectedItem.getCountryCode(), firstSelectedItem.getCurrency()); |
|||
showPaymentService(true, firstSelectedItem.getServiceAvailable()); |
|||
|
|||
|
|||
} |
|||
this.paymentServiceList = countryPaymentServiceList; |
|||
} |
|||
|
|||
@Override |
|||
public void showCountryServiceDataForListedNativeCountry(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryService, String recepientSeedValue) { |
|||
if (recepientSeedValue != null) { |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, false); |
|||
this.recieveMoneyEditText.setText(Utils.formatCurrency(recepientSeedValue)); |
|||
shouldCaulatedByRecipient = true; |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, true); |
|||
} |
|||
this.selectedCountryPaymentService = defaultCountryService; |
|||
this.selectedPaymentMode = defaultCountryService.getServiceAvailable().get(0); |
|||
this.paymentServiceList = countryPaymentServiceList; |
|||
showSelectedRecipient(defaultCountryService.getCountryCode(), defaultCountryService.getCurrency()); |
|||
showPaymentService(true, defaultCountryService.getServiceAvailable()); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void showCountryServiceDataForNonListedNativeCountry(List<CountryPaymentService> countryPaymentServiceList, String recepientSeedValue) { |
|||
if (recepientSeedValue != null) { |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, false); |
|||
this.sendMoneyEditText.setText(Utils.formatCurrency(recepientSeedValue)); |
|||
shouldCaulatedByRecipient = false; |
|||
recieveMoneyEditText.setText(""); |
|||
registerAvailableTextWatchersForEditText(this.sendMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(this.recieveMoneyEditText, true); |
|||
} |
|||
|
|||
CountryPaymentService firstSelectedItem = countryPaymentServiceList.get(0); |
|||
for (CountryPaymentService item : countryPaymentServiceList) { |
|||
if (item.getCountryCode().equalsIgnoreCase("NP")) { |
|||
firstSelectedItem = item; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
this.selectedCountryPaymentService = firstSelectedItem; |
|||
this.selectedPaymentMode = firstSelectedItem.getServiceAvailable().get(0); |
|||
this.paymentServiceList = countryPaymentServiceList; |
|||
showSelectedRecipient(firstSelectedItem.getCountryCode(), firstSelectedItem.getCurrency()); |
|||
showPaymentService(true, firstSelectedItem.getServiceAvailable()); |
|||
|
|||
} |
|||
|
|||
private void registerTextWatchers(boolean action) { |
|||
if (action) { |
|||
if (sendAmountTextWatcher == null) |
|||
sendAmountTextWatcher = new SendAmountTextWatcher(); |
|||
if (recepientAmountTextWatcher == null) |
|||
recepientAmountTextWatcher = new RecipientAmountTextWatcher(); |
|||
|
|||
if (recepientCurrencyFormatterTextWatcher == null) |
|||
recepientCurrencyFormatterTextWatcher = new CurrencyFormatterTextWatcher(recieveMoneyEditText); |
|||
if (sendCurrencyFormatterTextWatcher == null) |
|||
sendCurrencyFormatterTextWatcher = new CurrencyFormatterTextWatcher(sendMoneyEditText); |
|||
|
|||
|
|||
sendMoneyEditText.addTextChangedListener(sendAmountTextWatcher); |
|||
recieveMoneyEditText.addTextChangedListener(recepientAmountTextWatcher); |
|||
|
|||
sendMoneyEditText.addTextChangedListener(sendCurrencyFormatterTextWatcher); |
|||
recieveMoneyEditText.addTextChangedListener(recepientCurrencyFormatterTextWatcher); |
|||
} else { |
|||
sendMoneyEditText.removeTextChangedListener(sendAmountTextWatcher); |
|||
recieveMoneyEditText.addTextChangedListener(recepientCurrencyFormatterTextWatcher); |
|||
|
|||
sendMoneyEditText.addTextChangedListener(sendCurrencyFormatterTextWatcher); |
|||
recieveMoneyEditText.addTextChangedListener(recepientCurrencyFormatterTextWatcher); |
|||
} |
|||
} |
|||
|
|||
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 clearFocus() |
|||
{ |
|||
recieveMoneyEditText.clearFocus(); |
|||
sendMoneyEditText.clearFocus(); |
|||
} |
|||
|
|||
|
|||
private void prepareToGetForex() { |
|||
if (sendMoneyEditText.getText().length() > 0 || recieveMoneyEditText.getText().length() > 0) { |
|||
this.presenter.getForex(this.selectedCountryPaymentService, this.selectedPaymentMode, recieveMoneyEditText.getText().toString(), sendMoneyEditText.getText().toString(), shouldCaulatedByRecipient); |
|||
hideKeyBoard(); |
|||
} |
|||
else |
|||
showToastMessage("Please specify either of the amount."); |
|||
} |
|||
|
|||
@Override |
|||
public void updateExchangeRates(String recipientAmount, String sendAmount, String transferDisplay, String exRateDisplay) { |
|||
|
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, false); |
|||
|
|||
clearFocus(); |
|||
|
|||
this.recieveMoneyEditText.setText(Utils.formatCurrency(recipientAmount)); |
|||
this.sendMoneyEditText.setText(Utils.formatCurrency(sendAmount)); |
|||
|
|||
|
|||
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(); |
|||
|
|||
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(); |
|||
|
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, true); |
|||
|
|||
} |
|||
|
|||
private class SendAmountTextWatcher implements TextWatcher { |
|||
|
|||
@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 afterTextChanged(Editable s) { |
|||
shouldCaulatedByRecipient = false; |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, false); |
|||
recieveMoneyEditText.setText(""); |
|||
registerAvailableTextWatchersForEditText(recieveMoneyEditText, true); |
|||
} |
|||
} |
|||
|
|||
private class RecipientAmountTextWatcher implements TextWatcher { |
|||
|
|||
@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 afterTextChanged(Editable s) { |
|||
shouldCaulatedByRecipient = true; |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, false); |
|||
sendMoneyEditText.setText(""); |
|||
registerAvailableTextWatchersForEditText(sendMoneyEditText, true); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
private class AmountChangeAndFocusOutDetector extends GestureDetector.SimpleOnGestureListener { |
|||
|
|||
@Override |
|||
public boolean onSingleTapUp(MotionEvent e) { |
|||
if (e.getAction() == MotionEvent.ACTION_UP) { |
|||
if (hasValidOutsideAmountWidgetTouch(e.getX(), e.getY())) { |
|||
prepareToGetForex(); |
|||
return true; |
|||
|
|||
} |
|||
} |
|||
return super.onSingleTapUp(e); |
|||
} |
|||
|
|||
private boolean hasValidOutsideAmountWidgetTouch(float x, float y) { |
|||
|
|||
int posX=(int)x; |
|||
int posY=(int)y; |
|||
int[] sendMoneyLeftAndTopCoordinates = new int[2]; |
|||
|
|||
int[] receiveMoneyLeftAndTopCoordinates = new int[2]; |
|||
|
|||
int[] backButtonLeftAndTopCoordinates = new int[2]; |
|||
|
|||
|
|||
int[] calculateButtonLeftAndTopCoordinates = new int[2]; |
|||
|
|||
sendMoneyViewContainer.getLocationOnScreen(sendMoneyLeftAndTopCoordinates); |
|||
receiveMoneyViewContainer.getLocationOnScreen(receiveMoneyLeftAndTopCoordinates); |
|||
iv_back.getLocationOnScreen(backButtonLeftAndTopCoordinates); |
|||
exRateCalculateButton.getLocationOnScreen(calculateButtonLeftAndTopCoordinates); |
|||
|
|||
Rect sendMoneyBoundRect = new Rect(sendMoneyLeftAndTopCoordinates[0], sendMoneyLeftAndTopCoordinates[1], |
|||
sendMoneyLeftAndTopCoordinates[0] + sendMoneyViewContainer.getMeasuredWidth(), |
|||
sendMoneyLeftAndTopCoordinates[1] + sendMoneyViewContainer.getMeasuredHeight()); |
|||
|
|||
Rect receiveMoneyBoundRect = new Rect(receiveMoneyLeftAndTopCoordinates[0], receiveMoneyLeftAndTopCoordinates[1], |
|||
receiveMoneyLeftAndTopCoordinates[0] + receiveMoneyViewContainer.getMeasuredWidth(), |
|||
receiveMoneyLeftAndTopCoordinates[1] + receiveMoneyViewContainer.getMeasuredHeight()); |
|||
|
|||
Rect backButtonBoundRect = new Rect(backButtonLeftAndTopCoordinates[0], backButtonLeftAndTopCoordinates[1], |
|||
backButtonLeftAndTopCoordinates[0] + iv_back.getMeasuredWidth(), |
|||
backButtonLeftAndTopCoordinates[1] + iv_back.getMeasuredHeight()); |
|||
|
|||
|
|||
Rect calcButtonBoundRect = new Rect(calculateButtonLeftAndTopCoordinates[0], calculateButtonLeftAndTopCoordinates[1], |
|||
calculateButtonLeftAndTopCoordinates[0] + exRateCalculateButton.getMeasuredWidth(), |
|||
calculateButtonLeftAndTopCoordinates[1] + exRateCalculateButton.getMeasuredHeight()); |
|||
|
|||
|
|||
return (recieveMoneyEditText.hasFocus()||sendMoneyEditText.hasFocus()) |
|||
&&!sendMoneyBoundRect.contains(posX, posY) |
|||
&& !receiveMoneyBoundRect.contains(posX, posY) |
|||
&&!backButtonBoundRect.contains(posX, posY) |
|||
&&!calcButtonBoundRect.contains(posX,posY); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
private class SendMoneyFocusChangeListener implements View.OnFocusChangeListener { |
|||
|
|||
@Override |
|||
public void onFocusChange(View v, boolean hasFocus) { |
|||
if(hasFocus) |
|||
{ |
|||
rootView.postDelayed(()->{ |
|||
rootView.smoothScrollTo(0, rootView.getBottom()); |
|||
},250); |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.R; |
|||
|
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.model.datav2; |
|||
|
|||
import com.google.gson.annotations.Expose; |
|||
import com.google.gson.annotations.SerializedName; |
@ -1,10 +1,9 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.presenter; |
|||
|
|||
import com.gmeremit.online.gmeremittance_native.base.BaseContractInterface; |
|||
import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentMode; |
|||
import com.zoyi.channel.plugin.android.contract.BasePresenter; |
|||
import com.gmeremit.online.gmeremittance_native.exrate.model.datav2.CountryPaymentService; |
|||
import com.gmeremit.online.gmeremittance_native.exrate.model.datav2.PaymentMode; |
|||
|
|||
import java.util.List; |
|||
|
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.view; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.view; |
|||
|
|||
import android.support.v7.widget.RecyclerView; |
|||
import android.view.View; |
@ -1,4 +1,4 @@ |
|||
package com.gmeremit.online.gmeremittance_native.exchange_rate.view; |
|||
package com.gmeremit.online.gmeremittance_native.exrate.view; |
|||
|
|||
import android.content.Context; |
|||
import android.graphics.Canvas; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue