package com.ruigoncalo.marvin.ui;

import android.content.Context;
import android.widget.ImageView;

import com.ruigoncalo.marvin.model.raw.Thumbnail;
import com.squareup.picasso.Picasso;

/**
 * ImageLoaderManager that wraps up an image loader lib
 *
 * Currently using picasso
 *
 * Created by ruigoncalo on 20/04/16.
 */
public class ImageLoaderManager {

    private ImageLoaderManager(){

    }

    public static void load(Context context, String url, ImageView target) {
        Picasso.with(context).load(url).into(target);
    }

    public static void fetch(Context context, String url){
        Picasso.with(context).load(url).fetch();
    }

    /**
     * Build image url path
     * Font: http://developer.marvel.com/documentation/images
     *
     * @param thumbnail image url info
     * @return full url to download image
     */
    public static String buildImageUrl(Thumbnail thumbnail, boolean landscape){
        String path = thumbnail.getPath();
        String extension = thumbnail.getExtension();
        String imageSize = landscape ? "landscape_amazing" : "standard_large";

        return path + "/" + imageSize + "." + extension;
    }
}

@@ -352,16 +352,398 @@
 ager %7B%0A%0A
+    public static final int IMAGE_STANDARD = 0;%0A    public static final int IMAGE_LANDSCAPE = 1;%0A    public static final int IMAGE_PORTRAIT = 2;%0A%0A    private static final String IMAGE_FORMAT_STANDARD = %22standard_fantastic%22;%0A    private static final String IMAGE_FORMAT_LANDSCAPE = %22landscape_amazing%22;%0A    private static final String IMAGE_FORMAT_PORTRAIT = %22portrait_fantastic%22;%0A%0A%0A
     priv
@@ -1287,25 +1287,23 @@
 il, 
-boolean landscape
+int imageFormat
 )%7B%0A 
@@ -1428,58 +1428,33 @@
 e = 
-landscape ? %22landscape_amazing%22 : %22standard_large%22
+getImageSize(imageFormat)
 ;%0A%0A 
@@ -1515,10 +1515,447 @@
 ;%0A    %7D%0A
+%0A%0A    private static String getImageSize(int formart)%7B%0A        String result;%0A        switch (formart)%7B%0A            case IMAGE_LANDSCAPE:%0A                result = IMAGE_FORMAT_LANDSCAPE;%0A                break;%0A%0A            case IMAGE_PORTRAIT:%0A                result = IMAGE_FORMAT_PORTRAIT;%0A                break;%0A%0A            default: // standard%0A                result = IMAGE_FORMAT_STANDARD;%0A        %7D%0A%0A        return result;%0A    %7D%0A
 %7D%0A

Create image ratio builder