Picasso IntegrationΒΆ

If your app is using a custom Picasso singleton, you must initialize the Downloader object using an OkHttpClient instance created through the Neumob OkHttp API. Please see Neumob’s OkHttp integration guide for OkHttp and OkHttp3 for more details.

Picasso.setSingletonInstance must be called before initializing Neumob.

OkHttp2 sample code:

// If you are using OkHttp2, create a custom okhttp2 client through Neumob's API.
OkHttpClient okhttp2Client = Neumob.createOkHttpClient(builder);

// Create a Picasso instance using the downloader with the Neumob client
Picasso picasso = new Picasso.Builder(context)
    .downloader(new OkHttpDownloader(okhttp2Client))
    .build();

// Set the Picasso instance
Picasso.setSingletonInstance(picasso);

// Initialize Neumob after setSingletonInstance
Neumob.initialize(getApplicationContext(), "YOUR CLIENT KEY");

OkHttp3 sample code:

// Construct a builder if using a custom OkHttpClient
OkHttpClient.Builder builder = new OkHttpClient.Builder()
    .addInterceptor(new CustomLoggingInterceptor())
    .cache(new Cache(cacheDir, cacheSize));

// If you are using OkHttp3, create a custom okhttp3 client through Neumob's API.
OkHttpClient okhttp3Client = Neumob.createOkHttp3Client(builder);

// Create a Picasso instance using the downloader with the Neumob client
Picasso picasso = new Picasso.Builder(context)
    .downloader(new OkHttp3Downloader(okHttp3Client))
    .build();

// Set the Picasso instance
Picasso.setSingletonInstance(picasso);

// Initialize Neumob after setSingletonInstance
Neumob.initialize(getApplicationContext(), "YOUR CLIENT KEY");