package com.khmer9.yuki.screen.detail

import android.graphics.Color
import android.view.View
import android.widget.TextView
import com.gdtlib.lib.adapter.BaseListItem
import com.gdtlib.lib.viewholder.BaseListViewHolder
import com.khmer9.yuki.R

class BetsDetailListViewHolder(itemView: View, private val printButtonListener: ((String, String, String, String, String, String, String) -> Unit)? = null) : BaseListViewHolder(itemView) {
    override fun bindView(item: BaseListItem) {
        when (item) {
            is BettingDetailObject -> {
                val txtFightBet: TextView = itemView.findViewById(R.id.txt_fight_no)
                val txtTime: TextView = itemView.findViewById(R.id.txt_time)
                val txtAmount: TextView = itemView.findViewById(R.id.txt_amount)
                val txtType: TextView = itemView.findViewById(R.id.txt_type)

                val fightNo = "#" + item.no.toString()
                try {
                    var datetime = item.time.split(" ")
                    var time = datetime[1]
                    var date = datetime[0]
                    txtTime.text = date + System.getProperty("line.separator") + time
                } catch (e: Exception) {
                    txtTime.text = item.time
                }

                txtFightBet.text = fightNo
                txtAmount.text = item.amount

                try {
                    val amount = item.amount.split("=")
                    val winLose = amount[1].trim().toInt()
                    if (winLose == 0) {
                        txtAmount.setTextColor(Color.RED)
                    } else {
                        txtAmount.setTextColor(Color.rgb(48, 63, 159))
                    }
                } catch (e: Exception) {
                }
                txtType.text = item.betting
            }
        }
    }
}