@Test public void completeInvokesErrorOnAllFailedRequests() { Action action1 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget()); Action action2 = mockCanceledAction(); Exception exception = mock(Exception.class); BitmapHunter hunter = mockHunter(URI_KEY_1, null, false); when(hunter.getException()).thenReturn(exception); when(hunter.getActions()).thenReturn(Arrays.asList(action1, action2)); picasso.complete(hunter); verify(action1).error(exception); verify(action2, never()).error(exception); verify(listener).onImageLoadFailed(picasso, URI_1, exception); }
void complete(BitmapHunter hunter) { Action single = hunter.getAction(); List<Action> joined = hunter.getActions(); boolean hasMultiple = joined != null && !joined.isEmpty(); boolean shouldDeliver = single != null || hasMultiple; if (!shouldDeliver) { return; } Uri uri = hunter.getData().uri; Exception exception = hunter.getException(); Bitmap result = hunter.getResult(); LoadedFrom from = hunter.getLoadedFrom(); if (single != null) { deliverAction(result, from, single, exception); } if (hasMultiple) { for (int i = 0, n = joined.size(); i < n; i++) { Action join = joined.get(i); deliverAction(result, from, join, exception); } } if (listener != null && exception != null) { listener.onImageLoadFailed(this, uri, exception); } }
Picasso { void complete(BitmapHunter hunter) { Action single = hunter.getAction(); List<Action> joined = hunter.getActions(); boolean hasMultiple = joined != null && !joined.isEmpty(); boolean shouldDeliver = single != null || hasMultiple; if (!shouldDeliver) { return; } Uri uri = hunter.getData().uri; Exception exception = hunter.getException(); Bitmap result = hunter.getResult(); LoadedFrom from = hunter.getLoadedFrom(); if (single != null) { deliverAction(result, from, single, exception); } if (hasMultiple) { for (int i = 0, n = joined.size(); i < n; i++) { Action join = joined.get(i); deliverAction(result, from, join, exception); } } if (listener != null && exception != null) { listener.onImageLoadFailed(this, uri, exception); } } }
Picasso { void complete(BitmapHunter hunter) { Action single = hunter.getAction(); List<Action> joined = hunter.getActions(); boolean hasMultiple = joined != null && !joined.isEmpty(); boolean shouldDeliver = single != null || hasMultiple; if (!shouldDeliver) { return; } Uri uri = hunter.getData().uri; Exception exception = hunter.getException(); Bitmap result = hunter.getResult(); LoadedFrom from = hunter.getLoadedFrom(); if (single != null) { deliverAction(result, from, single, exception); } if (hasMultiple) { for (int i = 0, n = joined.size(); i < n; i++) { Action join = joined.get(i); deliverAction(result, from, join, exception); } } if (listener != null && exception != null) { listener.onImageLoadFailed(this, uri, exception); } } Picasso(Context context, Dispatcher dispatcher, Cache cache, Listener listener,
      RequestTransformer requestTransformer, List<RequestHandler> extraRequestHandlers, Stats stats,
      Bitmap.Config defaultBitmapConfig, boolean indicatorsEnabled, boolean loggingEnabled); }
Picasso { void complete(BitmapHunter hunter) { Action single = hunter.getAction(); List<Action> joined = hunter.getActions(); boolean hasMultiple = joined != null && !joined.isEmpty(); boolean shouldDeliver = single != null || hasMultiple; if (!shouldDeliver) { return; } Uri uri = hunter.getData().uri; Exception exception = hunter.getException(); Bitmap result = hunter.getResult(); LoadedFrom from = hunter.getLoadedFrom(); if (single != null) { deliverAction(result, from, single, exception); } if (hasMultiple) { for (int i = 0, n = joined.size(); i < n; i++) { Action join = joined.get(i); deliverAction(result, from, join, exception); } } if (listener != null && exception != null) { listener.onImageLoadFailed(this, uri, exception); } } Picasso(Context context, Dispatcher dispatcher, Cache cache, Listener listener,
      RequestTransformer requestTransformer, List<RequestHandler> extraRequestHandlers, Stats stats,
      Bitmap.Config defaultBitmapConfig, boolean indicatorsEnabled, boolean loggingEnabled); void cancelRequest(@NonNull ImageView view); void cancelRequest(@NonNull Target target); void cancelRequest(@NonNull RemoteViews remoteViews, @IdRes int viewId); void cancelTag(@NonNull Object tag); void pauseTag(@NonNull Object tag); void resumeTag(@NonNull Object tag); RequestCreator load(@Nullable Uri uri); RequestCreator load(@Nullable String path); RequestCreator load(@NonNull File file); RequestCreator load(@DrawableRes int resourceId); void invalidate(@Nullable Uri uri); void invalidate(@Nullable String path); void invalidate(@NonNull File file); @SuppressWarnings("UnusedDeclaration") void setIndicatorsEnabled(boolean enabled); @SuppressWarnings("UnusedDeclaration") boolean areIndicatorsEnabled(); @SuppressWarnings("UnusedDeclaration") // Public API. void setLoggingEnabled(boolean enabled); boolean isLoggingEnabled(); @SuppressWarnings("UnusedDeclaration") StatsSnapshot getSnapshot(); void shutdown(); static Picasso with(@NonNull Context context); static void setSingletonInstance(@NonNull Picasso picasso); }
Picasso { void complete(BitmapHunter hunter) { Action single = hunter.getAction(); List<Action> joined = hunter.getActions(); boolean hasMultiple = joined != null && !joined.isEmpty(); boolean shouldDeliver = single != null || hasMultiple; if (!shouldDeliver) { return; } Uri uri = hunter.getData().uri; Exception exception = hunter.getException(); Bitmap result = hunter.getResult(); LoadedFrom from = hunter.getLoadedFrom(); if (single != null) { deliverAction(result, from, single, exception); } if (hasMultiple) { for (int i = 0, n = joined.size(); i < n; i++) { Action join = joined.get(i); deliverAction(result, from, join, exception); } } if (listener != null && exception != null) { listener.onImageLoadFailed(this, uri, exception); } } Picasso(Context context, Dispatcher dispatcher, Cache cache, Listener listener,
      RequestTransformer requestTransformer, List<RequestHandler> extraRequestHandlers, Stats stats,
      Bitmap.Config defaultBitmapConfig, boolean indicatorsEnabled, boolean loggingEnabled); void cancelRequest(@NonNull ImageView view); void cancelRequest(@NonNull Target target); void cancelRequest(@NonNull RemoteViews remoteViews, @IdRes int viewId); void cancelTag(@NonNull Object tag); void pauseTag(@NonNull Object tag); void resumeTag(@NonNull Object tag); RequestCreator load(@Nullable Uri uri); RequestCreator load(@Nullable String path); RequestCreator load(@NonNull File file); RequestCreator load(@DrawableRes int resourceId); void invalidate(@Nullable Uri uri); void invalidate(@Nullable String path); void invalidate(@NonNull File file); @SuppressWarnings("UnusedDeclaration") void setIndicatorsEnabled(boolean enabled); @SuppressWarnings("UnusedDeclaration") boolean areIndicatorsEnabled(); @SuppressWarnings("UnusedDeclaration") // Public API. void setLoggingEnabled(boolean enabled); boolean isLoggingEnabled(); @SuppressWarnings("UnusedDeclaration") StatsSnapshot getSnapshot(); void shutdown(); static Picasso with(@NonNull Context context); static void setSingletonInstance(@NonNull Picasso picasso);  }