В Picasso.with(context)
..Почему в Picasso.with (контекст), Пикассо просит контекста?
public static Picasso with(Context context) {
if (singleton == null) {
synchronized (Picasso.class) {
if (singleton == null) {
singleton = new Builder(context).build();
}
}
}
return singleton;
}
и строитель (контекст Context), как это
/** Start building a new {@link Picasso} instance. */
public Builder(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context must not be null.");
}
this.context = context.getApplicationContext();
}
Почему Пикассо даже не спросив контексте, когда это всегда setting context = context.getApplicationContext()
?
Оно также предотвращает утечка «Activity» (если это то, что вы передаете), переключившись на контекст приложения. –
Большое спасибо @JakeWharton за ясность! –