package com.bomostory.sceneeditmodule.utils

import android.graphics.Rect
import android.support.v7.widget.RecyclerView
import android.view.View

class HorizontalItemDecoration(val spacing: Int) : RecyclerView.ItemDecoration() {

    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
        super.getItemOffsets(outRect, view, parent, state)

        when (parent.getChildLayoutPosition(view)) {
            0 -> {
                outRect.right = spacing / 2
            }
            parent.childCount - 1 -> {
                outRect.left = spacing / 2
            }
            else -> {
                outRect.right = spacing / 2
                outRect.left = spacing / 2
            }
        }
    }
}