com.squareup.picasso.OkHttp3Downloader Java Examples

The following examples show how to use com.squareup.picasso.OkHttp3Downloader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PicassoModule.java    From firebase-android-sdk with Apache License 2.0 8 votes vote down vote up
@Provides
@FirebaseAppScope
Picasso providesFiamController(
    Application application, PicassoErrorListener picassoErrorListener) {
  okhttp3.OkHttpClient client =
      new OkHttpClient.Builder()
          .addInterceptor(
              new Interceptor() {
                @Override
                public Response intercept(Chain chain) throws IOException {
                  return chain.proceed(
                      chain.request().newBuilder().addHeader("Accept", "image/*").build());
                }
              })
          .build();

  Picasso.Builder builder = new Picasso.Builder(application);
  builder.listener(picassoErrorListener).downloader(new OkHttp3Downloader(client));
  return builder.build();
}
 
Example #2
Source File: PicassoHandler.java    From android with MIT License 5 votes vote down vote up
private Picasso makePicasso() {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.cache(picassoCache);
    CertUtils.applySslSettings(builder, settings.sslSettings());
    OkHttp3Downloader downloader = new OkHttp3Downloader(builder.build());
    return new Picasso.Builder(context).downloader(downloader).build();
}
 
Example #3
Source File: SamplePicassoFactory.java    From fresco with MIT License 5 votes vote down vote up
public static Picasso getPicasso(Context context) {
  if (sPicasso == null) {
    sPicasso =
        new Picasso.Builder(context)
            .downloader(new OkHttp3Downloader(context, ConfigConstants.MAX_DISK_CACHE_SIZE))
            .memoryCache(new LruCache(ConfigConstants.MAX_MEMORY_CACHE_SIZE))
            .build();
  }
  return sPicasso;
}
 
Example #4
Source File: PicassoClient.java    From dropbox-sdk-java with MIT License 5 votes vote down vote up
public static void init(Context context, DbxClientV2 dbxClient) {

        // Configure picasso to know about special thumbnail requests
        sPicasso = new Picasso.Builder(context)
                .downloader(new OkHttp3Downloader(context))
                .addRequestHandler(new FileThumbnailRequestHandler(dbxClient))
                .build();
    }