// Path: app/src/main/java/com/joanzapata/iconify/internal/IconFontDescriptorWrapper.java
// public class IconFontDescriptorWrapper {
// 
//     private final IconFontDescriptor iconFontDescriptor;
// 
//     private final Map<String, Icon> iconsByKey;
// 
//     private Typeface cachedTypeface;
// 
//     public IconFontDescriptorWrapper(IconFontDescriptor iconFontDescriptor) {
//         this.iconFontDescriptor = iconFontDescriptor;
//         iconsByKey = new HashMap<String, Icon>();
//         Icon[] characters = iconFontDescriptor.characters();
//         for (int i = 0, charactersLength = characters.length; i < charactersLength; i++) {
//             Icon icon = characters[i];
//             iconsByKey.put(icon.key(), icon);
//         }
//     }
// 
//     public Icon getIcon(String key) {
//         return iconsByKey.get(key);
//     }
// 
//     public IconFontDescriptor getIconFontDescriptor() {
//         return iconFontDescriptor;
//     }
// 
//     public Typeface getTypeface(Context context) {
//         if (cachedTypeface != null) return cachedTypeface;
//         synchronized (this) {
//             if (cachedTypeface != null) return cachedTypeface;
//             cachedTypeface = Typeface.createFromAsset(context.getAssets(), iconFontDescriptor.ttfFileName());
//             return cachedTypeface;
//         }
//     }
// 
//     public boolean hasIcon(Icon icon) {
//         return iconsByKey.values().contains(icon);
//     }
// }


import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.TypedValue;
import com.joanzapata.iconify.internal.IconFontDescriptorWrapper;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
package com.joanzapata.iconify;



/**
 * Embed an icon into a Drawable that can be used as TextView icons, or ActionBar icons.
 * <pre>
 *     new IconDrawable(context, IconValue.icon_star)
 *           .colorRes(R.color.white)
 *           .actionBarSize();
 * </pre>
 * If you don't set the size of the drawable, it will use the size
 * that is given to him. Note that in an ActionBar, if you don't
 * set the size explicitly it uses 0, so please use actionBarSize().
 */
public class IconDrawable extends Drawable {

    public static final int ANDROID_ACTIONBAR_ICON_SIZE_DP = 24;

    private Context context;

    private Icon icon;

    private TextPaint paint;

    private int size = -1;

    private int alpha = 255;

    /**
     * Create an IconDrawable.
     * @param context Your activity or application context.
     * @param iconKey The icon key you want this drawable to display.
     * @throws IllegalArgumentException if the key doesn't match any icon.
     */
    public IconDrawable(Context context, String iconKey) {
        Icon icon = Iconify.findIconForKey(iconKey);
        if (icon == null) {
            throw new IllegalArgumentException("No icon with that key \"" + iconKey + "\".");
        }
        init(context, icon);
    }

    /**
     * Create an IconDrawable.
     * @param context Your activity or application context.
     * @param icon    The icon you want this drawable to display.
     */
    public IconDrawable(Context context, Icon icon) {
        init(context, icon);
    }

    private void init(Context context, Icon icon) {
        this.context = context;
        this.icon = icon;
        paint = new TextPaint();
// Path: app/src/main/java/com/joanzapata/iconify/internal/IconFontDescriptorWrapper.java
// public class IconFontDescriptorWrapper {
// 
//     private final IconFontDescriptor iconFontDescriptor;
// 
//     private final Map<String, Icon> iconsByKey;
// 
//     private Typeface cachedTypeface;
// 
//     public IconFontDescriptorWrapper(IconFontDescriptor iconFontDescriptor) {
//         this.iconFontDescriptor = iconFontDescriptor;
//         iconsByKey = new HashMap<String, Icon>();
//         Icon[] characters = iconFontDescriptor.characters();
//         for (int i = 0, charactersLength = characters.length; i < charactersLength; i++) {
//             Icon icon = characters[i];
//             iconsByKey.put(icon.key(), icon);
//         }
//     }
// 
//     public Icon getIcon(String key) {
//         return iconsByKey.get(key);
//     }
// 
//     public IconFontDescriptor getIconFontDescriptor() {
//         return iconFontDescriptor;
//     }
// 
//     public Typeface getTypeface(Context context) {
//         if (cachedTypeface != null) return cachedTypeface;
//         synchronized (this) {
//             if (cachedTypeface != null) return cachedTypeface;
//             cachedTypeface = Typeface.createFromAsset(context.getAssets(), iconFontDescriptor.ttfFileName());
//             return cachedTypeface;
//         }
//     }
// 
//     public boolean hasIcon(Icon icon) {
//         return iconsByKey.values().contains(icon);
//     }
// }


// Path: app/src/main/java/com/joanzapata/iconify/IconDrawable.java
import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.TypedValue;
import com.joanzapata.iconify.internal.IconFontDescriptorWrapper;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;

package com.joanzapata.iconify;



/**
 * Embed an icon into a Drawable that can be used as TextView icons, or ActionBar icons.
 * <pre>
 *     new IconDrawable(context, IconValue.icon_star)
 *           .colorRes(R.color.white)
 *           .actionBarSize();
 * </pre>
 * If you don't set the size of the drawable, it will use the size
 * that is given to him. Note that in an ActionBar, if you don't
 * set the size explicitly it uses 0, so please use actionBarSize().
 */
public class IconDrawable extends Drawable {

    public static final int ANDROID_ACTIONBAR_ICON_SIZE_DP = 24;

    private Context context;

    private Icon icon;

    private TextPaint paint;

    private int size = -1;

    private int alpha = 255;

    /**
     * Create an IconDrawable.
     * @param context Your activity or application context.
     * @param iconKey The icon key you want this drawable to display.
     * @throws IllegalArgumentException if the key doesn't match any icon.
     */
    public IconDrawable(Context context, String iconKey) {
        Icon icon = Iconify.findIconForKey(iconKey);
        if (icon == null) {
            throw new IllegalArgumentException("No icon with that key \"" + iconKey + "\".");
        }
        init(context, icon);
    }

    /**
     * Create an IconDrawable.
     * @param context Your activity or application context.
     * @param icon    The icon you want this drawable to display.
     */
    public IconDrawable(Context context, Icon icon) {
        init(context, icon);
    }

    private void init(Context context, Icon icon) {
        this.context = context;
        this.icon = icon;
        paint = new TextPaint();
        IconFontDescriptorWrapper descriptor = Iconify.findTypefaceOf(icon);