Skip to content Skip to sidebar Skip to footer

Picasso And Context

I have been playing lately with Picasso as an image loader library. I use it in conjunction with Dagger and OkHtttp. My only questions regarding this library are the usage of cont

Solution 1:

It doesn't matter which you choose, when using the default Picasso.with(Context) method, or the Builder, it will retrieve the application Context from the given Context:

/** Start building a new {@link Picasso} instance. */publicBuilder(Context context) {
  if (context == null) {
    thrownew IllegalArgumentException("Context must not be null.");
  }
  this.context = context.getApplicationContext();
}

Stub copied from Picasso.java#Builder.


If you actually want to create a new instance in each activity: For each instance of Picasso you create, you basically create a new cache: images cached in the first instance will not be reused in the second instance. You are very likely to run into OutOfMemoryExceptions here, as Picasso does not handle this.

Post a Comment for "Picasso And Context"