/*
 * Copyright 2014 Eduardo Barrenechea
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ca.barrenechea.widget.recyclerview.decoration;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;

/**
 * A simple and borderline useless divider decoration. Used mostly for testing and debugging purposes.
 * It will always draw a 1px thick black divider.
 */
public class DividerDecoration extends RecyclerView.ItemDecoration {

    private int mHeight;
    private Paint mPaint;

    public DividerDecoration(Context context) {
        mHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, 1f, context.getResources().getDisplayMetrics());
        mPaint = new Paint();
        mPaint.setColor(Color.BLACK);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
        int count = parent.getChildCount();

        for (int i = 0; i < count; i++) {
            final View child = parent.getChildAt(i);
            final int top = child.getTop();
            final int bottom = top + mHeight;
            final int left = child.getLeft();
            final int right = child.getRight();

            c.save();
            c.drawRect(left, top, right, bottom, mPaint);
            c.restore();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.set(0, 0, 0, mHeight);
    }
    
    /**
     * Set Color Divider
     */
    public void setColorDivider(int color) {
        mPaint.setColor(color);
    }
}

@@ -1196,16 +1196,61 @@
  mPaint;
+%0A    private int left;%0A    private int right;
 %0A%0A    pu
@@ -1482,14 +1482,50 @@
 lor.
-BLACK)
+GRAY);%0A        left = 0;%0A        right = 0
 ;%0A  
@@ -1732,17 +1732,17 @@
 int i = 
-0
+1
 ; i %3C co
@@ -1848,16 +1848,30 @@
 getTop()
+ - (mHeight/2)
 ;%0A      
@@ -1906,24 +1906,25 @@
  + mHeight;%0A
+%0A
             
@@ -1923,25 +1923,48 @@
         
-final int
+if (left == 0) %7B%0A               
  left = 
@@ -1992,26 +1992,36 @@
         
-final
+%7D%0A%0A           
  int 
+_
 right = 
@@ -2033,24 +2033,109 @@
 .getRight();
+%0A            if (right %3E 0) %7B%0A                _right = _right  - right;%0A            %7D
 %0A%0A          
@@ -2180,16 +2180,17 @@
 t, top, 
+_
 right, b
@@ -2432,23 +2432,17 @@
 , 0, 0, 
-mHeight
+0
 );%0A    %7D
@@ -2442,20 +2442,16 @@
 ;%0A    %7D%0A
-    
 %0A    /**
@@ -2466,21 +2466,206 @@
 Set 
-Color Divider
+Style Divider%0A     * @param color the divider color%0A     * @param thick the divider thickness%0A     * @param leftPadding the divider left padding%0A     * @param rightPadding the divider margin padding
 %0A   
@@ -2688,21 +2688,21 @@
 void set
-Color
+Style
 Divider(
@@ -2710,19 +2710,148 @@
 nt color
-) %7B
+, int thick, int leftPadding, int rightPadding) %7B%0A        left = leftPadding;%0A        right = rightPadding;%0A        mHeight = thick;
 %0A       
@@ -2875,16 +2875,17 @@
 color);%0A
+%0A
     %7D%0A%7D%0A

Remove setColorDivider, Add setStyleDivider