private static void defaultImage(ImageView imageView, int placeholderImageResource) {
   Log.d(THIS_FILE, "No uri, just display placeholder.");
   PhotoViewTag photoTag = new PhotoViewTag();
   photoTag.uri = null;
   imageView.setTag(TAG_PHOTO_INFOS, photoTag);
   imageView.setVisibility(View.VISIBLE);
   imageView.setImageResource(placeholderImageResource);
 }
  /**
   * Start an image load, attach the result to the specified CallerInfo object. Note, when the query
   * is started, we make the ImageView INVISIBLE if the placeholderImageResource value is -1. When
   * we're given a valid (!= -1) placeholderImageResource value, we make sure the image is visible.
   */
  public static final void updateImageViewWithContactPhotoAsync(
      int token,
      OnImageLoadCompleteListener listener,
      Object cookie,
      Context context,
      ImageView imageView,
      CallerInfo callerInfo,
      int placeholderImageResource) {
    if (sThreadHandler == null) {
      Log.d(THIS_FILE, "Update image view with contact async");
      new ContactsAsyncHelper();
    }

    // in case the source caller info is null, the URI will be null as well.
    // just update using the placeholder image in this case.
    if (callerInfo == null || callerInfo.contactContentUri == null) {
      defaultImage(imageView, placeholderImageResource);
      return;
    }

    // Check that the view is not already loading for same uri
    if (isAlreadyProcessed(imageView, callerInfo.contactContentUri)) {
      return;
    }

    // Added additional Cookie field in the callee to handle arguments
    // sent to the callback function.

    // setup arguments
    WorkerArgs args = new WorkerArgs();
    args.cookie = cookie;
    args.context = context;
    args.view = imageView;
    PhotoViewTag photoTag = new PhotoViewTag();
    photoTag.uri = callerInfo.contactContentUri;
    args.view.setTag(TAG_PHOTO_INFOS, photoTag);
    args.defaultResource = placeholderImageResource;
    args.listener = listener;

    // setup message arguments
    Message msg = sThreadHandler.obtainMessage(token);
    msg.arg1 = EVENT_LOAD_IMAGE;
    msg.obj = args;

    preloadImage(imageView, placeholderImageResource, msg);
  }
  public static void updateImageViewWithContactPhotoAsync(
      Context context, ImageView imageView, Uri photoUri, int placeholderImageResource) {
    if (sThreadHandler == null) {
      Log.d(THIS_FILE, "Update image view with contact async");
      new ContactsAsyncHelper();
    }

    // in case the source caller info is null, the URI will be null as well.
    // just update using the placeholder image in this case.
    if (photoUri == null) {
      defaultImage(imageView, placeholderImageResource);
      return;
    }
    if (isAlreadyProcessed(imageView, photoUri)) {
      return;
    }

    // Added additional Cookie field in the callee to handle arguments
    // sent to the callback function.

    // setup arguments
    WorkerArgs args = new WorkerArgs();
    args.context = context;
    args.view = imageView;
    PhotoViewTag photoTag = new PhotoViewTag();
    photoTag.uri = photoUri;
    args.view.setTag(TAG_PHOTO_INFOS, photoTag);
    args.defaultResource = placeholderImageResource;

    // setup message arguments
    Message msg = sThreadHandler.obtainMessage();
    msg.arg1 = EVENT_LOAD_IMAGE_URI;
    msg.obj = args;

    preloadImage(imageView, placeholderImageResource, msg);
  }