Skip to content

Instantly share code, notes, and snippets.

@kvofreelance
Created October 20, 2015 20:21
Show Gist options
  • Save kvofreelance/9568886c0b48cd6ab15c to your computer and use it in GitHub Desktop.
Save kvofreelance/9568886c0b48cd6ab15c to your computer and use it in GitHub Desktop.
NetworkService
package com.passengerapp.main.network;
import com.passengerapp.BuildConfig;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
/**
* Created by adventis on 10/15/15.
*/
public class NetworkService {
private final String END_POINT = BuildConfig.URL;
public NetworkApi getApi() {
return api;
}
private NetworkApi api;
public NetworkService() {
Retrofit service = new Retrofit.Builder()
.baseUrl(END_POINT)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
api = service.create(NetworkApi.class);
}
public NetworkService(String endPoint) {
Retrofit service = new Retrofit.Builder()
.baseUrl(endPoint)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
api = service.create(NetworkApi.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment