// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/transformation/CircleTransformation.java
// public class CircleTransformation implements Transformation {
// 
//   @Override public Bitmap transform(Bitmap source) {
//     int size = Math.min(source.getWidth(), source.getHeight());
//     int x = (source.getWidth() - size) / 2;
//     int y = (source.getHeight() - size) / 2;
//     Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
//     if (squaredBitmap != source) {
//       source.recycle();
//     }
//     Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//     Canvas canvas = new Canvas(bitmap);
//     Paint paint = new Paint();
//     BitmapShader shader =
//         new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
//     paint.setShader(shader);
//     paint.setAntiAlias(true);
//     float r = size / 2f;
//     canvas.drawCircle(r, r, r, paint);
//     squaredBitmap.recycle();
//     return bitmap;
//   }
// 
//   @Override public String key() {
//     return "Circle_Transformation";
//   }
// }


import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.imageloader.transformation.CircleTransformation;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
import com.squareup.picasso.Transformation;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
          .transform(transformations)
          .into(listenerTarget);
    } else if (hasResourceId || hasPlaceholder) {
      Resources resources = context.getResources();
      Drawable placeholder = null;
      Drawable drawable = null;
      if (hasPlaceholder) {
        placeholder = resources.getDrawable(placeholderId);
        listenerTarget.onPrepareLoad(placeholder);
      }
      if (hasResourceId) {
        drawable = resources.getDrawable(resourceId);
        listenerTarget.onDrawableLoad(drawable);
      }
    } else {
      throw new IllegalArgumentException(
          "Review your request, you are trying to load an image without a url or a resource id.");
    }
  }

  /**
   * Given a listener passed as argument creates or returns a lazy instance of a Picasso Target.
   * This implementation is needed because Picasso doesn't keep a strong reference to the target
   * passed as parameter. Without this method Picasso looses the reference to the target and never
   * notifies when the resource has been downloaded.
   *
   * Listener and Target instances are going to be stored into a WeakHashMap to avoid a memory leak
   * when ImageLoader client code is garbage collected.
   */
  private ListenerTarget getLinearTarget(final Listener listener) {
// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/transformation/CircleTransformation.java
// public class CircleTransformation implements Transformation {
// 
//   @Override public Bitmap transform(Bitmap source) {
//     int size = Math.min(source.getWidth(), source.getHeight());
//     int x = (source.getWidth() - size) / 2;
//     int y = (source.getHeight() - size) / 2;
//     Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
//     if (squaredBitmap != source) {
//       source.recycle();
//     }
//     Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
//     Canvas canvas = new Canvas(bitmap);
//     Paint paint = new Paint();
//     BitmapShader shader =
//         new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
//     paint.setShader(shader);
//     paint.setAntiAlias(true);
//     float r = size / 2f;
//     canvas.drawCircle(r, r, r, paint);
//     squaredBitmap.recycle();
//     return bitmap;
//   }
// 
//   @Override public String key() {
//     return "Circle_Transformation";
//   }
// }


// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/PicassoImageLoader.java
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.imageloader.transformation.CircleTransformation;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
import com.squareup.picasso.Transformation;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;

          .transform(transformations)
          .into(listenerTarget);
    } else if (hasResourceId || hasPlaceholder) {
      Resources resources = context.getResources();
      Drawable placeholder = null;
      Drawable drawable = null;
      if (hasPlaceholder) {
        placeholder = resources.getDrawable(placeholderId);
        listenerTarget.onPrepareLoad(placeholder);
      }
      if (hasResourceId) {
        drawable = resources.getDrawable(resourceId);
        listenerTarget.onDrawableLoad(drawable);
      }
    } else {
      throw new IllegalArgumentException(
          "Review your request, you are trying to load an image without a url or a resource id.");
    }
  }

  /**
   * Given a listener passed as argument creates or returns a lazy instance of a Picasso Target.
   * This implementation is needed because Picasso doesn't keep a strong reference to the target
   * passed as parameter. Without this method Picasso looses the reference to the target and never
   * notifies when the resource has been downloaded.
   *
   * Listener and Target instances are going to be stored into a WeakHashMap to avoid a memory leak
   * when ImageLoader client code is garbage collected.
   */
  private ListenerTarget getLinearTarget(final Listener listener) {
    ListenerTarget target = targets.get(listener);