package com.kdanmobile.reader.screen.reader.mediabox.signature

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


class SignatureRecyclerViewItemDecoration(private val space: Int, private val additionalPadding: Int) : RecyclerView.ItemDecoration() {

    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
        val position = parent.getChildAdapterPosition(view)
        val childCount = parent.adapter?.itemCount ?: 0
        outRect.bottom = when (position == childCount - 1) {
            true -> space + additionalPadding
            false -> space
        }
    }
}