package com.adealink.weparty.wallet.recharge.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.frame.aab.util.getCompatString
import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
import com.adealink.weparty.wallet.R
import com.adealink.weparty.wallet.databinding.LayoutRechargeErrorItemBinding
import com.adealink.weparty.wallet.recharge.data.RechargeErrorItemData
import com.adealink.weparty.wallet.recharge.data.RechargeListErrorType
import com.adealink.weparty.R as APP_R

class RechargeErrorItemViewBinder() :
    ItemViewBinder<RechargeErrorItemData, BindingViewHolder<LayoutRechargeErrorItemBinding>>() {
    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): BindingViewHolder<LayoutRechargeErrorItemBinding> {
        return BindingViewHolder(
            LayoutRechargeErrorItemBinding.inflate(
                inflater,
                parent,
                false
            )
        )
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(
        holder: BindingViewHolder<LayoutRechargeErrorItemBinding>,
        item: RechargeErrorItemData
    ) {
        when (item.errorType) {
            RechargeListErrorType.RechargeListEmpty -> {
                holder.binding.vError.show(
                    errorEmptyResId = APP_R.drawable.common_list_empty_ic,
                    title = APP_R.string.commonui_list_empty
                )
            }

            RechargeListErrorType.NetError -> {
                holder.binding.vError.show(
                    errorEmptyResId = APP_R.drawable.common_net_error_ic,
                    title = "${getCompatString(APP_R.string.common_net_error)}(${item.error})"
                )
            }

            RechargeListErrorType.GoogleNoInstall -> {
                holder.binding.vError.show(
                    errorEmptyResId = APP_R.drawable.common_list_empty_ic,
                    title = R.string.wallet_no_install_google
                )
            }
        }

    }


}