package com.e16din.lightutils.utils;

import android.content.res.ColorStateList;

/**
 * Created by e16din on 14.08.15.
 */
public class ColorUtils extends MathUtils {

    public static String hexToRgb(int color) {
        int c = (int) Long.parseLong(color + "", 16);
        String r = ((c >> 16) & 0xFF) + "";
        String g = ((c >> 8) & 0xFF) + "";
        String b = ((c) & 0xFF) + "";

        return r + g + b;
    }

    public static ColorStateList createSelector(int normalColor, int pressedColor) {
        return new ColorStateList(
                new int[][]
                        {
                                new int[]{android.R.attr.state_pressed},
                                new int[]{android.R.attr.state_focused},
                                new int[]{android.R.attr.state_activated},
                                new int[]{}
                        },
                new int[]
                        {
                                pressedColor,
                                pressedColor,
                                pressedColor,
                                normalColor
                        }
        );
    }
}

@@ -162,16 +162,271 @@
 tils %7B%0A%0A
+    public static String rgbToHex(int r, int g, int b) %7B%0A        return String.format(%22#%2502x%2502x%2502x%22, r, g, b);%0A    %7D%0A%0A    public static String argbToHex(int a, int r, int g, int b) %7B%0A        return String.format(%22#%2502x%2502x%2502x%2502x%22, a, r, g, b);%0A    %7D%0A%0A
     publ

Add rgbToHex().