package com.convenient.android.common.utils.decoration

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * @classname: SpacesItemDecoration
 * @author: LiuXiaoLong
 * @date: 2022-07-27 PM
 * description:
 */
class SpacesItemDecoration : RecyclerView.ItemDecoration {
    private var left = 0
    private var right = 0
    private var bottom = 0
    private var fistItemTop = 0

    private constructor() : super() {}

    constructor(space: Int) {
        left = space
        right = space
        bottom = space
        fistItemTop = space
    }

    /**
     * @构造函数
     * @说明:对recycleView的item的decoration进行配置
     * @param left
     * @param right
     * @param bottom
     * @param fistItemTop
     */
    constructor(left: Int, right: Int, bottom: Int, fistItemTop: Int) {
        this.left = left
        this.right = right
        this.fistItemTop = fistItemTop
        this.bottom = bottom
    }

    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
        outRect.left = left
        outRect.right = right
        outRect.top = fistItemTop
        outRect.bottom = bottom
    }

}