package android.support.v7.widget;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

public class MyRoundRectDrawableWithShadow extends RoundRectDrawableWithShadow {
    public MyRoundRectDrawableWithShadow(Resources resources, int backgroundColor, float radius, float shadowSize, float maxShadowSize) {
        super(resources, getColor(backgroundColor), radius, shadowSize, maxShadowSize);
        initRoundRectHelper();
    }

    private static ColorStateList getColor(int color) {
        return new ColorStateList(new int[][]{new int[]{android.R.attr.state_enabled}, new int[]{-android.R.attr.state_enabled}, new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_pressed}}, new int[]{color, color, color, color});
    }

    private void initRoundRectHelper() {
        RoundRectDrawableWithShadow.sRoundRectHelper = new RoundRectDrawableWithShadow.RoundRectHelper() {
            @Override
            public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius, Paint paint) {
                canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
            }
        };
    }
}
