package com.cooleshow.teacher.widgets;

import android.graphics.Rect;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import androidx.recyclerview.widget.RecyclerView;

/**
 * Author by pq, Date on 2021/3/18 0018.
 */
public class VideoCourseListItemDecoration extends RecyclerView.ItemDecoration {

    private int top;
    private int left;
    private int bottom;
    private int right;
    private int center;

    public VideoCourseListItemDecoration(int top, int left, int bottom, int right, int center) {
        this.top = top;
        this.left = left;
        this.bottom = bottom;
        this.right = right;
        this.center = center;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        //每行都只有2个
        int childLayoutPosition = parent.getChildLayoutPosition(view);
        outRect.top = top;
        outRect.bottom = bottom;
        if (childLayoutPosition % 2 == 0) {
            outRect.right = center;
            outRect.left = left;
        } else {
            outRect.left = center;
            outRect.right = right;
        }
    }
}
