package com.sambath.klaklouk_main.screen.result

import android.graphics.Color
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.gdtlib.lib.adapter.BaseListItem
import com.gdtlib.lib.viewholder.BaseListViewHolder
import com.sambath.klaklouk_main.R

class Table1ListViewHolder(itemView: View) : BaseListViewHolder(itemView) {
    private val ivCircle = itemView.findViewById<ImageView>(R.id.img_color)
    private val txtFightNo = itemView.findViewById<TextView>(R.id.txtFightNo)
    
    override fun bindView(item: BaseListItem) {
        when (item) {
            is Table1ListItem -> {
                with(item) {
                    try {
                        if (fightNo != 0) {
                            txtFightNo.text = fightNo.toString()
                            if (!item.color.isNullOrEmpty()) {
                                ivCircle.setColorFilter(Color.parseColor(item.color))
                            }
                        }
                    } catch (e: Exception) {
                    }
                }
            }
        }
    }
}