Browse Source

Exchange Rate first api flow to be tested

master
preyearegmi 6 years ago
parent
commit
4753e696b7
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 2
      .idea/misc.xml
  3. 14
      app/build.gradle
  4. 12
      app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java
  5. 14
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BasePresenter.java
  6. 6
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BasePresenterInterface.java
  7. 9
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGateway.java
  8. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGatewayInterface.java
  9. 28
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/gateway/ExchangeRateV2Gateway.java
  10. 44
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentServiceSeedValueModel.java
  11. 31
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java
  12. 12
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2InteractorInterface.java
  13. 114
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2Presenter.java
  14. 22
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2PresenterInterface.java
  15. 44
      app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java
  16. 1
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Constants.java
  17. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/API_URL.java
  18. 11
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/ApiEndpoints.java
  19. 68
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/GenericApiObservableResponse.java
  20. 24
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/GenericApiResponse.java
  21. 32
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HTTPConstants.java
  22. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java

BIN
.idea/caches/build_file_checksums.ser

2
.idea/misc.xml

@ -25,7 +25,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

14
app/build.gradle

@ -68,10 +68,14 @@ android {
shrinkResources false shrinkResources false
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible //noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0' implementation 'com.android.support:design:26.1.0'
@ -94,8 +98,7 @@ dependencies {
implementation 'com.github.kapilmhr:SizesDP:1.1' implementation 'com.github.kapilmhr:SizesDP:1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0' implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.facebook.android:facebook-share:[4,5)' implementation 'com.facebook.android:facebook-share:[4,5)'
// compile group: 'com.zendesk', name: 'sdk', version: '1.10.0.1'
// compile group: 'com.zendesk', name: 'sdk', version: '1.10.0.1'
implementation 'joda-time:joda-time:2.9.9' implementation 'joda-time:joda-time:2.9.9'
implementation 'com.jakewharton:butterknife:8.8.1' implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
@ -106,12 +109,7 @@ dependencies {
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0' implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

12
app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java

@ -1,6 +1,8 @@
package com.gmeremit.online.gmeremittance_native; package com.gmeremit.online.gmeremittance_native;
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.StrictMode; import android.os.StrictMode;
import android.support.multidex.MultiDex; import android.support.multidex.MultiDex;
@ -17,6 +19,8 @@ import java.lang.reflect.Method;
*/ */
public class GmeApplication extends Application { public class GmeApplication extends Application {
private static SharedPreferences gmeSharedPreferences = null;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -30,6 +34,8 @@ public class GmeApplication extends Application {
builder.detectFileUriExposure(); builder.detectFileUriExposure();
StrictMode.setVmPolicy(builder.build()); StrictMode.setVmPolicy(builder.build());
} }
gmeSharedPreferences= this.getSharedPreferences("GME", Context.MODE_PRIVATE);
/* if(Build.VERSION.SDK_INT>=24){ /* if(Build.VERSION.SDK_INT>=24){
try{ try{
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
@ -39,4 +45,10 @@ public class GmeApplication extends Application {
} }
}*/ }*/
} }
public static SharedPreferences getStorage() {
return gmeSharedPreferences;
}
} }

14
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BasePresenter.java

@ -1,4 +1,18 @@
package com.gmeremit.online.gmeremittance_native.base; package com.gmeremit.online.gmeremittance_native.base;
public class BasePresenter implements BasePresenterInterface { public class BasePresenter implements BasePresenterInterface {
@Override
public void onViewReady() {
}
@Override
public void onViewNotReady() {
}
@Override
public void onViewDestroyed() {
}
} }

6
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BasePresenterInterface.java

@ -1,4 +1,10 @@
package com.gmeremit.online.gmeremittance_native.base; package com.gmeremit.online.gmeremittance_native.base;
public interface BasePresenterInterface { public interface BasePresenterInterface {
void onViewReady();
void onViewNotReady();
void onViewDestroyed();
} }

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

@ -1,4 +1,11 @@
package com.gmeremit.online.gmeremittance_native.base; package com.gmeremit.online.gmeremittance_native.base;
public class PrivilegedGateway implements PrivilegedGatewayInterface {
import com.gmeremit.online.gmeremittance_native.GmeApplication;
public abstract class PrivilegedGateway implements PrivilegedGatewayInterface {
@Override
public String getAuth(){
return "Basic "+GmeApplication.getStorage().getString("ACCESS_CODE","");
}
} }

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

@ -1,4 +1,8 @@
package com.gmeremit.online.gmeremittance_native.base; package com.gmeremit.online.gmeremittance_native.base;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
public interface PrivilegedGatewayInterface extends BaseGatewayInterface { public interface PrivilegedGatewayInterface extends BaseGatewayInterface {
String getAuth();
} }

28
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/gateway/ExchangeRateV2Gateway.java

@ -0,0 +1,28 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.gateway;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
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 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<String> getNativeCountry() {
return Observable.just("Asdf");
}
@Override
public Observable<CountryPaymentServiceSeedValueModel> getAllSeedVAlues(String nativeCountry) {
return Observable.just(new CountryPaymentServiceSeedValueModel("asdf","asdf"));
}
}

44
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/CountryPaymentServiceSeedValueModel.java

@ -0,0 +1,44 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2;
import com.google.gson.annotations.SerializedName;
public class CountryPaymentServiceSeedValueModel {
@SerializedName("countryCode")
String countryCode;
@SerializedName("currency")
String currency;
@SerializedName("recipientSeedValue")
String recipientSeedValue;
public CountryPaymentServiceSeedValueModel(String countryCode, String recipientSeedValue) {
this.countryCode = countryCode;
this.recipientSeedValue = recipientSeedValue;
}
public String getCountryCode() {
return countryCode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getRecipientSeedValue() {
return recipientSeedValue;
}
public void setRecipientSeedValue(String recipientSeedValue) {
this.recipientSeedValue = recipientSeedValue;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
}

31
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/model/datav2/PaymentServiceApiResponse.java

@ -0,0 +1,31 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2;
import java.util.ArrayList;
import java.util.List;
public class PaymentServiceApiResponse {
List<CountryPaymentService> countryPaymentServices;
public PaymentServiceApiResponse() {
countryPaymentServices=new ArrayList<>();
}
public List<CountryPaymentService> getCountryPaymentServices() {
return countryPaymentServices;
}
public void setCountryPaymentServices(List<CountryPaymentService> countryPaymentServices) {
this.countryPaymentServices = countryPaymentServices;
}
public CountryPaymentService getCountryPaymentServiceFromCountryCodeAndCurrency(String countryCode,String currency){
for(CountryPaymentService countryPaymentService:countryPaymentServices)
{
if(countryPaymentService.getCountryCode().equalsIgnoreCase(countryCode)&&countryPaymentService.getCurrency().equalsIgnoreCase(currency))
return countryPaymentService;
}
return null;
}
}

12
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2InteractorInterface.java

@ -2,17 +2,23 @@ package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter;
import com.gmeremit.online.gmeremittance_native.base.BaseGatewayInterface; import com.gmeremit.online.gmeremittance_native.base.BaseGatewayInterface;
import com.gmeremit.online.gmeremittance_native.base.BaseInteractorInterface; 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.CountryPaymentService;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import java.util.List; import java.util.List;
import io.reactivex.Observable;
public interface ExchangeRateV2InteractorInterface extends BaseInteractorInterface { public interface ExchangeRateV2InteractorInterface extends BaseInteractorInterface {
void onGettinPaymentServiceInforFromServer(List<CountryPaymentService> data);
interface ExchangeRateV2GatewayInterface extends BaseGatewayInterface
interface ExchangeRateV2GatewayInterface extends PrivilegedGatewayInterface
{ {
//Change to observable rxjava //Change to observable rxjava
void getPaymentServiceInfoFromServer();
Observable<PaymentServiceApiResponse> getPaymentServiceInfoFromServer(String auth);
String getNativeCountry();
Observable<List<CountryPaymentServiceSeedValueModel>> getAllSeedVAlues();
} }
} }

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

@ -1,18 +1,114 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.presenter; 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.base.PrivilegedGatewayInterface;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService;
import android.util.Log;
import java.util.List;
import com.gmeremit.online.gmeremittance_native.base.BasePresenter;
import com.gmeremit.online.gmeremittance_native.exchange_rate.gateway.ExchangeRateV2Gateway;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentServiceSeedValueModel;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObservableResponse;
public interface ExchangeRateV2Presenter extends BasePresenterInterface {
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
void getCountryServiceData();
public class ExchangeRateV2Presenter extends BasePresenter implements ExchangeRateV2PresenterInterface, ExchangeRateV2InteractorInterface {
interface ExchangeRateV2ContractInterface extends PrivilegedGatewayInterface
private final ExchangeRateV2ContractInterface view;
private final ExchangeRateV2GatewayInterface gateway;
private final CompositeDisposable compositeDisposables;
public ExchangeRateV2Presenter(ExchangeRateV2ContractInterface view) {
this.view = view;
this.gateway = new ExchangeRateV2Gateway();
this.compositeDisposables = new CompositeDisposable();
}
@Override
public void getAllData() {
compositeDisposables.add(
Observable.zip(getPaymentServiceInfo(), getDefaultValue(), PaymentServiceData::new)
.doOnSubscribe(disposable -> this.view.showProgressBar(true, "Fetching Exchange Rates..."))
.doOnError((err) -> this.view.showProgressBar(false, ""))
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new PaymentServiceDataObservable())
);
}
@Override
public void getForex() {
}
private Observable<CountryPaymentServiceSeedValueModel> getDefaultValue() {
return this.gateway.getAllSeedVAlues().flatMap(seedValueList->{
String nativeCountryCode= this.gateway.getNativeCountry();
for(CountryPaymentServiceSeedValueModel seedValueModel:seedValueList)
{ {
void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList);
if(seedValueModel.getCountryCode().equalsIgnoreCase(nativeCountryCode))
return Observable.just(seedValueModel);
}
return Observable.just(new CountryPaymentServiceSeedValueModel(null,null));
});
}
private Observable<PaymentServiceApiResponse> getPaymentServiceInfo() {
return this.gateway.getPaymentServiceInfoFromServer(this.gateway.getAuth()).subscribeOn(Schedulers.io());
}
public class PaymentServiceDataObservable extends GenericApiObservableResponse<PaymentServiceData> {
@Override
protected void onSuccess(PaymentServiceData paymentServiceApiResponse) {
Log.d("ExchangeV2", "Success");
CountryPaymentServiceSeedValueModel seedValueModel = paymentServiceApiResponse.getCountryPaymentServiceSeedValueModel();
view.showCountryServiceData(paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServices(),
paymentServiceApiResponse.getPaymentServiceApiResponse().getCountryPaymentServiceFromCountryCodeAndCurrency(seedValueModel.getCountryCode(), seedValueModel.getCurrency()),
paymentServiceApiResponse.getCountryPaymentServiceSeedValueModel().getRecipientSeedValue()
);
}
@Override
public void onFailed(String message) {
Log.d("ExchangeV2", "Failed:" + message);
}
@Override
protected void onConnectionNotEstablished(String message) {
Log.d("ExchangeV2", "ConnectionNotEstablished:" + message);
}
}
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;
}
} }
} }

22
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/presenter/ExchangeRateV2PresenterInterface.java

@ -0,0 +1,22 @@
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.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 java.util.List;
public interface ExchangeRateV2PresenterInterface extends BasePresenterInterface {
void getAllData();
void getForex();
interface ExchangeRateV2ContractInterface extends BaseContractInterface
{
void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList, CountryPaymentService defaultCountryService,String recepientSeedValue);
}
}

44
app/src/main/java/com/gmeremit/online/gmeremittance_native/exchange_rate/view/ExchangeMethodV2Activity.java

@ -1,7 +1,6 @@
package com.gmeremit.online.gmeremittance_native.exchange_rate.view; package com.gmeremit.online.gmeremittance_native.exchange_rate.view;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
@ -11,13 +10,17 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.gmeremit.online.gmeremittance_native.R; import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomPaddingRv;
import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView; import com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView;
import com.gmeremit.online.gmeremittance_native.customwidgets.countrylistingdialog.CountryFlagMapper; import com.gmeremit.online.gmeremittance_native.customwidgets.countrylistingdialog.CountryFlagMapper;
import com.gmeremit.online.gmeremittance_native.customwidgets.countrylistingdialog.CountryListingDialog; import com.gmeremit.online.gmeremittance_native.customwidgets.countrylistingdialog.CountryListingDialog;
import com.gmeremit.online.gmeremittance_native.exchange_rate.adapter.PaymentModeRvAdapter; import com.gmeremit.online.gmeremittance_native.exchange_rate.adapter.PaymentModeRvAdapter;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.CountryPaymentService; 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.PaymentMode; 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.Constants;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -25,7 +28,7 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
public class ExchangeMethodV2Activity extends AppCompatActivity implements PaymentModeRvAdapter.OnPaymentModeSelectionListener, CountryListingDialog.CountrySelectionListener, View.OnClickListener {
public class ExchangeMethodV2Activity extends BaseActivity implements PaymentModeRvAdapter.OnPaymentModeSelectionListener, CountryListingDialog.CountrySelectionListener, View.OnClickListener, ExchangeRateV2PresenterInterface.ExchangeRateV2ContractInterface {
@BindView(R.id.sendAmountEdTxt) @BindView(R.id.sendAmountEdTxt)
EditText sendMoneyEditText; EditText sendMoneyEditText;
@ -51,8 +54,10 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme
private PaymentModeRvAdapter paymentModeRvAdapter; private PaymentModeRvAdapter paymentModeRvAdapter;
private PaymentMode selectedPaymentMode; private PaymentMode selectedPaymentMode;
private List<CountryPaymentService> mockedData; private List<CountryPaymentService> mockedData;
private List<CountryPaymentService> paymentServiceList;
private CountryListingDialog countryListingDialog; private CountryListingDialog countryListingDialog;
private CountryPaymentService selectedCountryPaymentService; private CountryPaymentService selectedCountryPaymentService;
private ExchangeRateV2PresenterInterface presenter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -66,11 +71,14 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme
private void init() { private void init() {
setupRv(); setupRv();
this.presenter=new ExchangeRateV2Presenter(this);
} }
private void performDefaultAction(Bundle savedInstanceState) { private void performDefaultAction(Bundle savedInstanceState) {
toolbarTitle.setText("Today's Rate"); toolbarTitle.setText("Today's Rate");
mockData(); mockData();
this.presenter.getAllData();
} }
@ -101,7 +109,6 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme
paymentModeRvAdapter = new PaymentModeRvAdapter(this); paymentModeRvAdapter = new PaymentModeRvAdapter(this);
paymentModeRv.setAdapter(paymentModeRvAdapter); paymentModeRv.setAdapter(paymentModeRvAdapter);
paymentModeRv.addItemDecoration(new SelectedRedBorderDecoration(this)); paymentModeRv.addItemDecoration(new SelectedRedBorderDecoration(this));
// paymentModeRv.addItemDecoration(new CustomPaddingRv(10));
paymentModeRv.setItemAnimator(new DefaultItemAnimator()); paymentModeRv.setItemAnimator(new DefaultItemAnimator());
} }
@ -136,12 +143,17 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme
public void onCountrySelected(CountryPaymentService countryPaymentService) { public void onCountrySelected(CountryPaymentService countryPaymentService) {
Log.d("ExchangeRateV2", "Selected Country " + countryPaymentService.getCountryCode()); Log.d("ExchangeRateV2", "Selected Country " + countryPaymentService.getCountryCode());
this.selectedCountryPaymentService=countryPaymentService; this.selectedCountryPaymentService=countryPaymentService;
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(countryPaymentService.getCountryCode()));
this.recepientCurrencyTextView.setText(countryPaymentService.getCurrency());
showSelectedRecipient(countryPaymentService.getCountryCode(),countryPaymentService.getCurrency());
if (this.countryListingDialog != null) if (this.countryListingDialog != null)
this.countryListingDialog.dismiss(); this.countryListingDialog.dismiss();
} }
private void showSelectedRecipient(String selectedCountryCode,String selectedCountryCurrency)
{
this.recepientFlagImageView.setBackgroundResource(CountryFlagMapper.getFlagFromCountryCode(selectedCountryCode));
this.recepientCurrencyTextView.setText(selectedCountryCurrency);
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
@ -150,4 +162,24 @@ public class ExchangeMethodV2Activity extends AppCompatActivity implements Payme
break; break;
} }
} }
@Override
public void showCountryServiceData(List<CountryPaymentService> countryPaymentServiceList,CountryPaymentService defaultCountryPaymentService,String seedValue) {
showSelectedRecipient(defaultCountryPaymentService.getCountryCode(),defaultCountryPaymentService.getCurrency());
if(seedValue!=null) {
this.recepientCurrencyTextView.setText(seedValue);
}
else
{
this.sendMoneyEditText.setText(Constants.DEFAULT_EXCHANGE_SEND_AMOUNT);
this.recepientCurrencyTextView.setText("");
}
this.paymentServiceList=countryPaymentServiceList;
this.selectedCountryPaymentService=defaultCountryPaymentService;
this.presenter.getForex();
}
} }

1
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/Constants.java

@ -127,6 +127,7 @@ public class Constants {
public static final String RECIPIENT_UPDATE = "RECIPIENT_UPDATE"; public static final String RECIPIENT_UPDATE = "RECIPIENT_UPDATE";
// User Request // User Request
public static final String USER_REQUEST_PAGE = "USER_REQUEST_PAGE"; public static final String USER_REQUEST_PAGE = "USER_REQUEST_PAGE";
public static final String DEFAULT_EXCHANGE_SEND_AMOUNT = "";
// public static final String DEVICEID = "gme1234apps12sanam"; // public static final String DEVICEID = "gme1234apps12sanam";
/* public static final String DEVICEID = "iakhycas"; new@test.com pw: test*/ /* public static final String DEVICEID = "iakhycas"; new@test.com pw: test*/
// public static String key = Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + DEVICEID); // public static String key = Utils.toBase64("172017F9EC11222E8107142733:QRK2UM0Q:" + DEVICEID);

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/API_URL.java

@ -116,5 +116,9 @@ public class API_URL {
public static final String RELATION_LIST = "cdds/CDDRELV1"; public static final String RELATION_LIST = "cdds/CDDRELV1";
public static final String STATE_LIST = "cdds/CDDPRLSTV1"; public static final String STATE_LIST = "cdds/CDDPRLSTV1";
public static final String DISTRICT_LIST = "cdds/CDDDTLSTV1"; public static final String DISTRICT_LIST = "cdds/CDDDTLSTV1";
/* V2 Api Endpoints */
public static final String EXCHANGE_RATE_SERVICE="mobile/countriesServices";
} }

11
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/ApiEndpoints.java

@ -4,6 +4,7 @@ import com.gmeremit.online.gmeremittance_native.customer_support.model.Amendment
import com.gmeremit.online.gmeremittance_native.customer_support.model.Suggestion; import com.gmeremit.online.gmeremittance_native.customer_support.model.Suggestion;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.data.Currency; import com.gmeremit.online.gmeremittance_native.exchange_rate.model.data.Currency;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.data.ExchangeRateResponse; import com.gmeremit.online.gmeremittance_native.exchange_rate.model.data.ExchangeRateResponse;
import com.gmeremit.online.gmeremittance_native.exchange_rate.model.datav2.PaymentServiceApiResponse;
import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData; import com.gmeremit.online.gmeremittance_native.gme_branches.model.data.PayoutLocationData;
import com.gmeremit.online.gmeremittance_native.home.model.data.FireToken; import com.gmeremit.online.gmeremittance_native.home.model.data.FireToken;
import com.gmeremit.online.gmeremittance_native.home.model.data.Profile; import com.gmeremit.online.gmeremittance_native.home.model.data.Profile;
@ -85,10 +86,12 @@ import com.gmeremit.online.gmeremittance_native.wallet_to_wallet.model.WalletReq
import com.gmeremit.online.gmeremittance_native.wallet_to_wallet.model.WalletResponse; import com.gmeremit.online.gmeremittance_native.wallet_to_wallet.model.WalletResponse;
import com.gmeremit.online.gmeremittance_native.wallet_to_wallet.model.WalletUserInfo; import com.gmeremit.online.gmeremittance_native.wallet_to_wallet.model.WalletUserInfo;
import com.gmeremit.online.gmeremittance_native.withdraw.model.WithDraw; import com.gmeremit.online.gmeremittance_native.withdraw.model.WithDraw;
import com.google.gson.JsonObject;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
@ -96,6 +99,7 @@ import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.DELETE; import retrofit2.http.DELETE;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers; import retrofit2.http.Headers;
import retrofit2.http.Multipart; import retrofit2.http.Multipart;
import retrofit2.http.PATCH; import retrofit2.http.PATCH;
@ -512,4 +516,11 @@ public interface ApiEndpoints {
@GET(API_URL.DISTRICT_LIST) @GET(API_URL.DISTRICT_LIST)
@Headers("Content-Type: application/json") @Headers("Content-Type: application/json")
Call<List<District>> getDistrictList(@Query("countryId") String countryId, @Query("provinceId") String provinceId); Call<List<District>> getDistrictList(@Query("countryId") String countryId, @Query("provinceId") String provinceId);
/* V2 */
@POST(API_URL.EXCHANGE_RATE_SERVICE)
@Headers("Content-Type: application/json")
Observable<PaymentServiceApiResponse> getPaymentServiceV2(@Header("Authorization") String token);
} }

68
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/GenericApiObservableResponse.java

@ -0,0 +1,68 @@
package com.gmeremit.online.gmeremittance_native.utils.https;
import org.json.JSONObject;
import java.io.IOException;
import java.net.SocketTimeoutException;
import io.reactivex.observers.DisposableObserver;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
/**
* Created by Preyea R. Regmi
* Use this wrapper class to abstract application wise network response for rx-retrofit 2.0 and above
*/
public abstract class GenericApiObservableResponse<T> extends DisposableObserver<T> {
protected abstract void onSuccess(T t);
public abstract void onFailed(String message);
protected abstract void onConnectionNotEstablished(String message);
@Override
public void onNext(T t) {
//Handle application wise response code here
String errorMessage = checkIfResponseIsValidOrNot(t);
if (errorMessage == null)
onSuccess(t);
else
onFailed(errorMessage);
}
@Override
public void onError(Throwable e) {
if (e instanceof HttpException) {
onFailed(HTTPConstants.getErrorMessageFromCode(((HttpException) e).code()));
} else if (e instanceof SocketTimeoutException) {
onFailed(HTTPConstants.HTTP_RESPONSE_NO_INTERNET);
} else if (e instanceof IOException) {
onConnectionNotEstablished(HTTPConstants.HTTP_RESPONSE_NO_INTERNET);
} else {
onFailed(e.getMessage());
}
}
@Override
public void onComplete() {
}
private String checkIfResponseIsValidOrNot(T genericBody) {
try {
ResponseBody responseBody = (ResponseBody) genericBody;
JSONObject jsonObject = new JSONObject(responseBody.string());
if (jsonObject.getString("errorCode").equalsIgnoreCase(HTTPConstants.APPLICATION_WISE_ERROR_KEY))
return jsonObject.getString("responseDescription");
else
return null;
} catch (Exception e) {
return e.getMessage();
}
}
}

24
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/GenericApiResponse.java

@ -4,6 +4,10 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
/**
* Created by Preyea R. Regmi
* Use this wrapper class to abstract application wise network response for retrofit 2.0 and above
*/
public class GenericApiResponse<T> implements Callback<T> { public class GenericApiResponse<T> implements Callback<T> {
private GenericApiResponseListener<T> listener; private GenericApiResponseListener<T> listener;
@ -17,25 +21,7 @@ public class GenericApiResponse<T> implements Callback<T> {
if (response.isSuccessful()) { if (response.isSuccessful()) {
listener.onSuccess(response.body()); listener.onSuccess(response.body());
} else { } else {
switch (response.code()) {
case 401:
listener.onError(HTTPConstants.HTTP_RESPONSE_401);
break;
case 403:
listener.onError(HTTPConstants.HTTP_RESPONSE_403);
break;
case 500:
listener.onError(HTTPConstants.HTTP_RESPONSE_500);
break;
case 404:
listener.onError(HTTPConstants.HTTP_RESPONSE_500);
break;
}
listener.onError(HTTPConstants.getErrorMessageFromCode(response.code()));
} }
} }

32
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HTTPConstants.java

@ -1,8 +1,32 @@
package com.gmeremit.online.gmeremittance_native.utils.https; package com.gmeremit.online.gmeremittance_native.utils.https;
public class HTTPConstants { public class HTTPConstants {
public static final String HTTP_RESPONSE_401 = "";
public static final String HTTP_RESPONSE_403 = "";
public static final String HTTP_RESPONSE_500 = "";
public static final String HTTP_RESPONSE_NO_INTERNET = "";
public static final String HTTP_RESPONSE_401 = "401";
public static final String HTTP_RESPONSE_403 = "403";
public static final String HTTP_RESPONSE_500 = "500";
public static final String HTTP_RESPONSE_NO_INTERNET = "No internet";
public static final String HTTP_RESPONSE_UNKNOWN = "Unknown Error";
public static final String APPLICATION_WISE_ERROR_KEY = "1";
public static String getErrorMessageFromCode(int errorCode) {
switch (errorCode) {
case 401:
return HTTP_RESPONSE_401;
case 403:
return HTTPConstants.HTTP_RESPONSE_403;
case 500:
return HTTPConstants.HTTP_RESPONSE_500;
case 404:
return HTTPConstants.HTTP_RESPONSE_500;
default:
return HTTPConstants.HTTP_RESPONSE_NO_INTERNET;
}
}
} }

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/https/HttpClientV2.java

@ -17,7 +17,7 @@ public class HttpClientV2 {
private static ApiEndpoints apiInterface; private static ApiEndpoints apiInterface;
/** /**
* Creates an instance for API Interface
* Creates an instance for Http Client Interface
* *
* @return apiInterface * @return apiInterface
*/ */

Loading…
Cancel
Save