package com.hainaos.vc.view;

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

import androidx.recyclerview.widget.RecyclerView;

/**
 * RecycleView item 间距设置
 */
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int left, right, bottom, top;

    public SpacesItemDecoration(int space) {
        this.left = space;
        this.right = space;
        this.bottom = space;
        this.top = space;
    }

    public SpacesItemDecoration(int top, int bottom, boolean flag) {
        this.top = top;
        this.bottom = bottom;
        this.left = 0;
        this.right = 0;
    }

    public SpacesItemDecoration(int left, int right) {
        this.left = left;
        this.right = right;
        this.bottom = 0;
        this.top = 0;
    }

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

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {
        outRect.left = left;
        outRect.right = right;
        outRect.bottom = bottom;
        outRect.top = top;
    }
}