|
|
@ -18,9 +18,14 @@ import com.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageMode |
|
|
|
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 com.gmeremit.online.gmeremittance_native.utils.https.HTTPConstants; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.security.SecurityUtils; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.security.SignatureCheck; |
|
|
|
import com.mtramin.rxfingerprint.data.FingerprintAuthenticationException; |
|
|
|
import com.scottyab.rootbeer.RootBeer; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.net.SocketTimeoutException; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
@ -29,6 +34,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
|
|
import io.reactivex.observers.DisposableObserver; |
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
import io.reactivex.subjects.PublishSubject; |
|
|
|
|
|
|
|
public class SplashScreenPresenter extends BasePresenter implements SplashScreenPresenterInterface, SplashScreenInteractorInterface { |
|
|
|
|
|
|
@ -39,6 +45,9 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
private final CompositeDisposable compositeDisposables; |
|
|
|
private final String sendCountryDefault = "118"; |
|
|
|
|
|
|
|
final PublishSubject<Object> retrySubject = PublishSubject.create(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Exrate Related Data |
|
|
@ -195,13 +204,12 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
|
|
|
|
@Override |
|
|
|
public void calcExrate() { |
|
|
|
view.hideKeyBoard(); |
|
|
|
if(selectedCountryPaymentService==null) |
|
|
|
return; |
|
|
|
if(!validateAmount()) |
|
|
|
{ |
|
|
|
view.showToastMessage(getStringfromStringId(R.string.sending_amount_error)); |
|
|
|
return; |
|
|
|
} |
|
|
|
String calculateFlag = calcByPayoutAmount ? Constants.CALC_BY_RECIPEINT : Constants.CALC_BY_SENDER; |
|
|
|
view.hideKeyBoard(); |
|
|
|
compositeDisposables.add( |
|
|
|
this.gateway.sendDataForForexCalculation(gateway.getAuth(), |
|
|
|
sendCountryDefault, |
|
|
@ -218,9 +226,17 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
} |
|
|
|
|
|
|
|
private boolean validateAmount() { |
|
|
|
if(calcByPayoutAmount&&pAmount.length()>1) |
|
|
|
|
|
|
|
if(calcByPayoutAmount&&pAmount.length()<1) { |
|
|
|
view.showToastMessage(getStringfromStringId(R.string.receiving_amount_error)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
else if(!calcByPayoutAmount&&cAmount.length()<1) |
|
|
|
{ |
|
|
|
view.showToastMessage(getStringfromStringId(R.string.sending_amount_error)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
else return !calcByPayoutAmount && cAmount.length() > 1; |
|
|
|
} |
|
|
|
|
|
|
|
private Observable<CountryPaymentServiceSeedValueModel> getDefaultValue(String countryCode) { |
|
|
@ -282,27 +298,25 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
view.showPopUpMessage(paymentServiceApiResponse.paymentServiceApiResponse.getMessage(), CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
view.animateToExrateView(null); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailed(String message) { |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT_RETRY, alertType -> { new Handler().postDelayed(SplashScreenPresenter.this::getExrateRelatedData,200); }); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); |
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT_RETRY, alertType -> { new Handler().postDelayed(SplashScreenPresenter.this::getExrateRelatedData,200); }); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void unauthorizedAccess(String message) { |
|
|
|
gateway.clearAllUserData(); |
|
|
|
|
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout()); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.exitView()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -348,14 +362,13 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailed(String message) { |
|
|
|
// view.clearExrateAndServiceCharge(); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView()); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onConnectionNotEstablished(String message) { |
|
|
|
// view.clearExrateAndServiceCharge(); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, alertType -> view.exitView()); |
|
|
|
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -367,28 +380,6 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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() { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class PaymentServiceData { |
|
|
|
private PaymentServiceApiResponse paymentServiceApiResponse; |
|
|
|