package com.adealink.weparty.commonui.recycleview.commonviewholder

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.LayoutCommonListEmptyBinding
import com.adealink.weparty.R as APP_R

/**
 * 列表空数据ViewHolder
 */
class CommonListEmptyViewBinder :
    ItemViewBinder<CommonListEmptyItemData, BindingViewHolder<LayoutCommonListEmptyBinding>>() {
    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): BindingViewHolder<LayoutCommonListEmptyBinding> {
        return BindingViewHolder(LayoutCommonListEmptyBinding.inflate(inflater, parent, false))
    }

    override fun onBindViewHolder(
        holder: BindingViewHolder<LayoutCommonListEmptyBinding>,
        item: CommonListEmptyItemData
    ) {
        when (item.emptyType) {
            CommonListErrorEmptyType.NoData -> {
                holder.binding.emptyErrorView.show(
                    APP_R.drawable.common_list_empty_ic,
                    APP_R.string.commonui_list_empty
                )
            }

            CommonListErrorEmptyType.NetError -> {
                holder.binding.emptyErrorView.show(
                    APP_R.drawable.common_net_error_ic,
                    APP_R.string.common_net_error
                )
            }
        }
    }
}