package com.adealink.weparty.imageselect.view

import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
import com.adealink.weparty.databinding.ItemAddBinding
import com.adealink.weparty.imageselect.listener.OnOperateListener
import com.adealink.weparty.imageselect.model.AddInfo
import com.adealink.weparty.imageselect.model.MediaType

class AddItemViewBinder(private val l: OnOperateListener) :
    ItemViewBinder<AddInfo, BindingViewHolder<ItemAddBinding>>() {

    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): BindingViewHolder<ItemAddBinding> {
        return BindingViewHolder(ItemAddBinding.inflate(inflater, parent, false))
    }

    override fun onBindViewHolder(holder: BindingViewHolder<ItemAddBinding>, item: AddInfo) {
        holder.binding.root.setOnClickListener {
            when (item.mediaType) {
                MediaType.ALL -> l.onTakeAll()
                MediaType.IMAGE -> l.onTakePhoto()
                MediaType.VIDEO -> l.onTakeVideo()
            }
        }
    }

}