Clean up
This commit is contained in:
parent
c48c2dadaf
commit
6fb17d7b55
2 changed files with 6 additions and 26 deletions
|
|
@ -19,48 +19,32 @@ import java.io.InputStream;
|
|||
|
||||
public class ArtistImageLoader implements StreamModelLoader<ArtistImage> {
|
||||
private Context context;
|
||||
private LastFMRestClient lastFMRestClient;
|
||||
private LastFMRestClient lastFMClient;
|
||||
private ModelLoader<GlideUrl, InputStream> urlLoader;
|
||||
|
||||
public ArtistImageLoader(Context context, LastFMRestClient lastFMRestClient, ModelLoader<GlideUrl, InputStream> urlLoader) {
|
||||
this.context = context;
|
||||
this.lastFMRestClient = lastFMRestClient;
|
||||
this.lastFMClient = lastFMRestClient;
|
||||
this.urlLoader = urlLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFetcher<InputStream> getResourceFetcher(ArtistImage model, int width, int height) {
|
||||
return new ArtistImageFetcher(context, lastFMRestClient, model, urlLoader, width, height);
|
||||
return new ArtistImageFetcher(context, lastFMClient, model, urlLoader, width, height);
|
||||
}
|
||||
|
||||
public static class Factory implements ModelLoaderFactory<ArtistImage, InputStream> {
|
||||
private static volatile LastFMRestClient internalClient;
|
||||
private LastFMRestClient client;
|
||||
private LastFMRestClient lastFMClient;
|
||||
private OkHttpUrlLoader.Factory okHttpFactory;
|
||||
|
||||
|
||||
private static LastFMRestClient getInternalClient(Context context) {
|
||||
if (internalClient == null) {
|
||||
synchronized (Factory.class) {
|
||||
if (internalClient == null) {
|
||||
internalClient = new LastFMRestClient(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return internalClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for a new Factory that runs requests using a static singleton client.
|
||||
*/
|
||||
public Factory(Context context) {
|
||||
client = getInternalClient(context);
|
||||
okHttpFactory = new OkHttpUrlLoader.Factory();
|
||||
lastFMClient = new LastFMRestClient(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelLoader<ArtistImage, InputStream> build(Context context, GenericLoaderFactory factories) {
|
||||
return new ArtistImageLoader(context, client, okHttpFactory.build(context, factories));
|
||||
return new ArtistImageLoader(context, lastFMClient, okHttpFactory.build(context, factories));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import com.squareup.okhttp.Response;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import retrofit.GsonConverterFactory;
|
||||
import retrofit.Retrofit;
|
||||
|
|
@ -33,9 +32,6 @@ public class LastFMRestClient {
|
|||
okHttpClient.setCache(new Cache(cacheDir, 1024 * 1024 * 10));
|
||||
}
|
||||
|
||||
okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);
|
||||
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
|
||||
|
||||
okHttpClient.interceptors().add(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue