images/src/main/java/com/stanfy/enroscar/images/ImagesManager.java
private void startImageLoaderTask(final ImageConsumer consumer, final ImageRequest request) {
    final String key = request.getKey();
    if (debug) { Log.d(TAG, "Key " + key); }

    ImageLoader loader = currentLoads.get(key);
    if (loader != null) {
      final boolean added = loader.addTarget(consumer);
      if (!added) { loader = null; }
    }

    if (loader == null) {

      if (debug) { Log.d(TAG, "Start a new task"); }
      loader = new ImageLoader(request, this);
      if (!loader.addTarget(consumer)) {
        throw new IllegalStateException("Cannot add target to the new loader");
      }

      currentLoads.put(key, loader);
      if (debug) { Log.d(TAG, "Current loaders count: " + currentLoads.size()); }
      final Executor executor = getImageTaskExecutor();
      executor.execute(loader.future);

    } else if (debug) {
      Log.d(TAG, "Joined to the existing task " + key);
    }
  }
private void startImageLoaderTask(final ImageConsumer consumer, final ImageRequest request) {
    final String key = request.getKey();
    if (debug) { Log.d(TAG, "Key " + key); }

    ImageLoader loader = currentLoads.get(key);
    if (loader != null) {
      final boolean added = loader.addTarget(consumer);
      if (!added) { loader = null; }
    }

    if (loader == null) {

      if (debug) { Log.d(TAG, "Start a new task"); }
      loader = new ImageLoader(request, this);
      if (!loader.addTarget(consumer)) {
        throw new IllegalStateException("Cannot add target to the new loader");
      }

      currentLoads.put(key, loader);
      if (debug) { Log.d(TAG, "Current loaders count: " + currentLoads.size()); }
      final Executor executor = getImageTaskExecutor();
      executor.execute(loader.future);

    } else if (debug) {
      Log.d(TAG, "Joined to the existing task " + key);
    }
  }
private void startImageLoaderTask ( final ImageConsumer consumer , final ImageRequest request ) { final String key = request . getKey ( ) ; if ( debug ) { Log . d ( TAG , "Key " + key ) ; } ImageLoader loader = currentLoads . get ( key ) ; if ( loader != null ) { final boolean added = loader . addTarget ( consumer ) ; if ( ! added ) { loader = null ; } } if ( loader == null ) { if ( debug ) { Log . d ( TAG , "Start a new task" ) ; } loader = new ImageLoader ( request , this ) ; if ( ! loader . addTarget ( consumer ) ) { throw new IllegalStateException ( "Cannot add target to the new loader" ) ; } currentLoads . put ( key , loader ) ; if ( debug ) { Log . d ( TAG , "Current loaders count: " + currentLoads . size ( ) ) ; } final Executor executor = getImageTaskExecutor ( ) ; executor . execute ( loader . future ) ; } else if ( debug ) { Log . d ( TAG , "Joined to the existing task " + key ) ; } }
Executed in the main thread.
@param request image request
@param consumer image holder to process
Executed in the main thread .