// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
//     /**
//      * Load the image at the given url and return it as a Bitmap.
//      * @param context The current context.
//      * @param url The image's url.
//      * @return A bitmap of the image.
//      */
//     Bitmap loadImage(Context context, String url);
// 
//     /**
//      * Load the image at the given url and return it as a Bitmap in the provided size..
//      * @param context The current context.
//      * @param url The image's url.
//      * @param width Requested width of the image.
//      * @param height Requested height of the image.
//      * @return A bitmap.
//      */
//     Bitmap loadImage(Context context, String url, int width, int height);
// }
// 
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
//     public BadParameterException(String message) {
//         super(message);
//     }
// 
//     public BadParameterException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException;

    /**
     * Parses a color value hex string into its integer representation. If it's not a hex string, it
     * tries to interpret {@param colorValue} as a resource identifier.
     *
     * @throws {@link NumberFormatException} if {@param colorValue} was not a hex string.
     * @throws {@link BadParameterException} if the color value could not be parsed.
     * @return Color int value.
     */
    public static int getColorInt(String colorValue) {
        Matcher m = COLOR_VALUE_PATTERN.matcher(colorValue);
        if (!m.find()) {
            throw new NumberFormatException();
        }

        colorValue = m.group(1);
        int colorLength = colorValue.length();

        if (colorLength == 3) {
            int raw = Integer.parseInt(colorValue, 16);
            // 0xFFFFFF
            int first = (raw & 0xF00) >> 8;
            int second = (raw & 0x0F0) >> 4;
            int third = raw & 0x00F;
            return (0xFF << 24) | (first << 20) | (first << 16) | (second << 12) | (second << 8) | (third << 4) | third;
        } else if (colorLength == 6) {
            return (0xFF << 24) | Integer.parseInt(colorValue, 16);
        } else if (colorLength == 8) {
            return (int) Long.parseLong(colorValue, 16);
        }
// Path: library/src/main/java/co/jasonwyatt/srml/SRMLImageLoader.java
// public interface SRMLImageLoader {
//     /**
//      * Load the image at the given url and return it as a Bitmap.
//      * @param context The current context.
//      * @param url The image's url.
//      * @return A bitmap of the image.
//      */
//     Bitmap loadImage(Context context, String url);
// 
//     /**
//      * Load the image at the given url and return it as a Bitmap in the provided size..
//      * @param context The current context.
//      * @param url The image's url.
//      * @param width Requested width of the image.
//      * @param height Requested height of the image.
//      * @return A bitmap.
//      */
//     Bitmap loadImage(Context context, String url, int width, int height);
// }
// 
// Path: library/src/main/java/co/jasonwyatt/srml/tags/BadParameterException.java
// public class BadParameterException extends RuntimeException {
//     public BadParameterException(String message) {
//         super(message);
//     }
// 
//     public BadParameterException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: library/src/main/java/co/jasonwyatt/srml/utils/Utils.java
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.DisplayMetrics;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import co.jasonwyatt.srml.SRMLImageLoader;
import co.jasonwyatt.srml.tags.BadParameterException;


    /**
     * Parses a color value hex string into its integer representation. If it's not a hex string, it
     * tries to interpret {@param colorValue} as a resource identifier.
     *
     * @throws {@link NumberFormatException} if {@param colorValue} was not a hex string.
     * @throws {@link BadParameterException} if the color value could not be parsed.
     * @return Color int value.
     */
    public static int getColorInt(String colorValue) {
        Matcher m = COLOR_VALUE_PATTERN.matcher(colorValue);
        if (!m.find()) {
            throw new NumberFormatException();
        }

        colorValue = m.group(1);
        int colorLength = colorValue.length();

        if (colorLength == 3) {
            int raw = Integer.parseInt(colorValue, 16);
            // 0xFFFFFF
            int first = (raw & 0xF00) >> 8;
            int second = (raw & 0x0F0) >> 4;
            int third = raw & 0x00F;
            return (0xFF << 24) | (first << 20) | (first << 16) | (second << 12) | (second << 8) | (third << 4) | third;
        } else if (colorLength == 6) {
            return (0xFF << 24) | Integer.parseInt(colorValue, 16);
        } else if (colorLength == 8) {
            return (int) Long.parseLong(colorValue, 16);
        }
        throw new BadParameterException("could not parse color value: "+colorValue);