package com.simplecity.amp_library.http;
import com.simplecity.amp_library.lastfm.ItunesService;
import com.simplecity.amp_library.lastfm.LastFmService;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class HttpClient {
public static final String TAG = "HttpClient";
private static final String URL_LAST_FM = "http://ws.audioscrobbler.com/2.0/";
private static final String URL_ITUNES = "https://itunes.apple.com/search/";
private static HttpClient sInstance;
public OkHttpClient okHttpClient;
public LastFmService lastFmService;
public ItunesService itunesService;
public static final String TAG_ARTWORK = "artwork";
public static synchronized HttpClient getInstance() {
if (sInstance == null) {
sInstance = new HttpClient();
}
return sInstance;
}
private HttpClient() {
okHttpClient = new OkHttpClient.Builder()
// .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.0.3", 8888)))
.build();
Retrofit lastFmRestAdapter = new Retrofit.Builder()
.baseUrl(URL_LAST_FM)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
lastFmService = lastFmRestAdapter.create(LastFmService.class);
Retrofit itunesRestAdapter = new Retrofit.Builder()
.baseUrl(URL_ITUNES)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
itunesService = itunesRestAdapter.create(ItunesService.class);
}
}