package com.atmob.keyboard_android.component.item

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.atmob.keyboard_android.R
import com.atmob.keyboard_android.model.EmptyPlaceholderModel
import me.drakeet.multitype.ItemViewBinder

/**
 * 空占位条目
 */
class EmptyPlaceholderViewBinder :
    ItemViewBinder<EmptyPlaceholderModel, EmptyPlaceholderViewBinder.InnerViewHolder>() {
    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): InnerViewHolder {
        return InnerViewHolder(inflater.inflate(R.layout.item_empty_placeholder, parent, false))
    }

    override fun onBindViewHolder(
        holder: InnerViewHolder,
        item: EmptyPlaceholderModel
    ) {
        holder.vItemPlaceholder.apply {
            layoutParams.height = item.height
            requestLayout()
        }
    }

    inner class InnerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val vItemPlaceholder: View = itemView.findViewById(R.id.item_placeholder)
    }
}