package com.gdtlib.lib.viewholder

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.gdtlib.lib.adapter.BaseListItem

abstract class BaseListViewHolder(
    itemView: View
) : RecyclerView.ViewHolder(itemView) {

    abstract fun bindView(item: BaseListItem)

    fun setClickListener(clickListener: ((Int) -> Unit)?) {
        if (clickListener != null) {
            itemView.setOnClickListener {
                clickListener(adapterPosition)
            }
        } else {
            itemView.setOnClickListener(null)
        }
    }
    companion object{
        fun  getCurrency(currency: Int): String{
            val short = currency/1000
            return "${short}K"
        }
        fun getBettingId(playNo:String, playDate: String) : String {
            val playID = playNo.subSequence(0,playNo.length-5)
            val playTime = playDate.subSequence(playDate.length -8, playDate.length-3)
            return "$playID $playTime"
        }

        fun getTypeOfBetting(type: String): String{
            return when(type){
                "Small" -> "U"
                "Large" -> "O"
                else -> type
            }
        }

        fun convertToTypeOfBetting(type: String): String{
            return when(type){
                "U" -> "Small"
                "O" -> "Large"
                else -> type
            }
        }
    }
}