package com.prolificinteractive.materialcalendarview.sample.decorators;

import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;

import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade;

import java.util.Calendar;

/**
 * Highlight Saturdays and Sundays with a background
 */
public class HighlightWeekendsDecorator implements DayViewDecorator {

    private final Calendar calendar = Calendar.getInstance();
    private final Drawable highlightDrawable;

    public HighlightWeekendsDecorator() {
        highlightDrawable = generateBackgroundDrawable();
    }

    @Override
    public boolean shouldDecorate(CalendarDay day) {
        day.copyTo(calendar);
        int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
        return weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY;
    }

    @Override
    public void decorate(DayViewFacade view) {
        view.setBackgroundDrawable(highlightDrawable);
    }

    private static Drawable generateBackgroundDrawable() {
        final int r = 0;
        final float[] outerR = new float[] {r, r, r, r, r, r, r, r};
        final int color = Color.parseColor("#228BC34A");

        RoundRectShape rr = new RoundRectShape(outerR, null, null);

        ShapeDrawable drawable = new ShapeDrawable(rr);
        drawable.setShaderFactory(new ShapeDrawable.ShaderFactory() {
            @Override
            public Shader resize(int width, int height) {
                return new LinearGradient(0, 0, 0, 0, color, color, Shader.TileMode.REPEAT);
            }
        });
        return drawable;
    }
}

@@ -101,80 +101,8 @@
 or;%0A
-import android.graphics.LinearGradient;%0Aimport android.graphics.Shader;%0A
 impo
@@ -130,16 +130,21 @@
 rawable.
+Color
 Drawable
@@ -178,21 +178,16 @@
 rawable.
-Shape
 Drawable
@@ -191,64 +191,8 @@
 ble;
-%0Aimport android.graphics.drawable.shapes.RoundRectShape;
 %0A%0Aim
@@ -659,16 +659,84 @@
 rawable;
+%0A    private static final int color = Color.parseColor(%22#228BC34A%22);
 %0A%0A    pu
@@ -799,34 +799,25 @@
 wable = 
-generateBackground
+new Color
 Drawable
@@ -817,16 +817,21 @@
 rawable(
+color
 );%0A    %7D
@@ -1194,644 +1194,7 @@
    %7D
-%0A%0A    private static Drawable generateBackgroundDrawable() %7B%0A        final int r = 0;%0A        final float%5B%5D outerR = new float%5B%5D %7Br, r, r, r, r, r, r, r%7D;%0A        final int color = Color.parseColor(%22#228BC34A%22);%0A%0A        RoundRectShape rr = new RoundRectShape(outerR, null, null);%0A%0A        ShapeDrawable drawable = new ShapeDrawable(rr);%0A        drawable.setShaderFactory(new ShapeDrawable.ShaderFactory() %7B%0A            @Override%0A            public Shader resize(int width, int height) %7B%0A                return new LinearGradient(0, 0, 0, 0, color, color, Shader.TileMode.REPEAT);%0A            %7D%0A        %7D);%0A        return drawable;%0A    %7D
 %0A%7D%0A

Use ColorDrawable in HighlightWeekendsDecorator