@Test public void performRetryDoesNotMarkForReplayIfNoNetworkScanning() { BitmapHunter hunter = mockHunter(URI_KEY_1, bitmap1, false, mockAction(URI_KEY_1, URI_1)); when(hunter.shouldRetry(anyBoolean(), any(NetworkInfo.class))).thenReturn(false); when(hunter.supportsReplay()).thenReturn(true); Dispatcher dispatcher = createDispatcher(false); dispatcher.performRetry(hunter); assertThat(dispatcher.hunterMap).isEmpty(); assertThat(dispatcher.failedActions).isEmpty(); verify(service, never()).submit(hunter); }
void performRetry(BitmapHunter hunter) { if (hunter.isCancelled()) return; if (service.isShutdown()) { performError(hunter, false); return; } NetworkInfo networkInfo = null; if (scansNetworkChanges) { ConnectivityManager connectivityManager = getService(context, CONNECTIVITY_SERVICE); networkInfo = connectivityManager.getActiveNetworkInfo(); } if (hunter.shouldRetry(airplaneMode, networkInfo)) { if (hunter.getPicasso().loggingEnabled) { log(OWNER_DISPATCHER, VERB_RETRYING, getLogIdsForHunter(hunter)); } if (hunter.getException() instanceof NetworkRequestHandler.ContentLengthException) { hunter.networkPolicy |= NetworkPolicy.NO_CACHE.index; } hunter.future = service.submit(hunter); } else { boolean willReplay = scansNetworkChanges && hunter.supportsReplay(); performError(hunter, willReplay); if (willReplay) { markForReplay(hunter); } } }
Dispatcher { void performRetry(BitmapHunter hunter) { if (hunter.isCancelled()) return; if (service.isShutdown()) { performError(hunter, false); return; } NetworkInfo networkInfo = null; if (scansNetworkChanges) { ConnectivityManager connectivityManager = getService(context, CONNECTIVITY_SERVICE); networkInfo = connectivityManager.getActiveNetworkInfo(); } if (hunter.shouldRetry(airplaneMode, networkInfo)) { if (hunter.getPicasso().loggingEnabled) { log(OWNER_DISPATCHER, VERB_RETRYING, getLogIdsForHunter(hunter)); } if (hunter.getException() instanceof NetworkRequestHandler.ContentLengthException) { hunter.networkPolicy |= NetworkPolicy.NO_CACHE.index; } hunter.future = service.submit(hunter); } else { boolean willReplay = scansNetworkChanges && hunter.supportsReplay(); performError(hunter, willReplay); if (willReplay) { markForReplay(hunter); } } } }
Dispatcher { void performRetry(BitmapHunter hunter) { if (hunter.isCancelled()) return; if (service.isShutdown()) { performError(hunter, false); return; } NetworkInfo networkInfo = null; if (scansNetworkChanges) { ConnectivityManager connectivityManager = getService(context, CONNECTIVITY_SERVICE); networkInfo = connectivityManager.getActiveNetworkInfo(); } if (hunter.shouldRetry(airplaneMode, networkInfo)) { if (hunter.getPicasso().loggingEnabled) { log(OWNER_DISPATCHER, VERB_RETRYING, getLogIdsForHunter(hunter)); } if (hunter.getException() instanceof NetworkRequestHandler.ContentLengthException) { hunter.networkPolicy |= NetworkPolicy.NO_CACHE.index; } hunter.future = service.submit(hunter); } else { boolean willReplay = scansNetworkChanges && hunter.supportsReplay(); performError(hunter, willReplay); if (willReplay) { markForReplay(hunter); } } } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats); }
Dispatcher { void performRetry(BitmapHunter hunter) { if (hunter.isCancelled()) return; if (service.isShutdown()) { performError(hunter, false); return; } NetworkInfo networkInfo = null; if (scansNetworkChanges) { ConnectivityManager connectivityManager = getService(context, CONNECTIVITY_SERVICE); networkInfo = connectivityManager.getActiveNetworkInfo(); } if (hunter.shouldRetry(airplaneMode, networkInfo)) { if (hunter.getPicasso().loggingEnabled) { log(OWNER_DISPATCHER, VERB_RETRYING, getLogIdsForHunter(hunter)); } if (hunter.getException() instanceof NetworkRequestHandler.ContentLengthException) { hunter.networkPolicy |= NetworkPolicy.NO_CACHE.index; } hunter.future = service.submit(hunter); } else { boolean willReplay = scansNetworkChanges && hunter.supportsReplay(); performError(hunter, willReplay); if (willReplay) { markForReplay(hunter); } } } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats);  }
Dispatcher { void performRetry(BitmapHunter hunter) { if (hunter.isCancelled()) return; if (service.isShutdown()) { performError(hunter, false); return; } NetworkInfo networkInfo = null; if (scansNetworkChanges) { ConnectivityManager connectivityManager = getService(context, CONNECTIVITY_SERVICE); networkInfo = connectivityManager.getActiveNetworkInfo(); } if (hunter.shouldRetry(airplaneMode, networkInfo)) { if (hunter.getPicasso().loggingEnabled) { log(OWNER_DISPATCHER, VERB_RETRYING, getLogIdsForHunter(hunter)); } if (hunter.getException() instanceof NetworkRequestHandler.ContentLengthException) { hunter.networkPolicy |= NetworkPolicy.NO_CACHE.index; } hunter.future = service.submit(hunter); } else { boolean willReplay = scansNetworkChanges && hunter.supportsReplay(); performError(hunter, willReplay); if (willReplay) { markForReplay(hunter); } } } Dispatcher(Context context, ExecutorService service, Handler mainThreadHandler,
      Downloader downloader, Cache cache, Stats stats);   }