package com.zxhl.main.page.view

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.chat.SignEntity
import com.zxhl.cms.net.model.chat.SignList
import com.zxhl.cms.utils.PhoneUtils
import com.zxhl.cms.utils.Utils
import com.zxhl.main.R

class SignAdapter : BaseRecyclerAdapter<SignList, SignAdapter.ViewHolder> {
    private var mContext: Context? = null

    private val mWhiteColor: Int
    private val mBlackColor: Int
    private val mPaperColor: Int
    constructor(
        content: Context?
    ) : super() {
        mContext = content
        mWhiteColor = AppContext.get().resources.getColor(com.zxhl.cms.R.color.white)
        mBlackColor = AppContext.get().resources.getColor(com.zxhl.cms.R.color.color_333333)
        mPaperColor = AppContext.get().resources.getColor(com.zxhl.cms.R.color.color_aa60ff)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        var bean = mList[position]
        if(bean.status==2){
            holder.item_rl?.setBackgroundResource(R.drawable.shape_b19aff_6736ff_r5)
            holder.id_img_days?.setImageResource(R.drawable.icon_jiaobiao_qiandao)
            holder.id_img_star_coin?.setImageResource(R.drawable.icon_xingbi_qiandao)
            holder.id_tv_bottom_coin?.setTextColor(mWhiteColor)
            holder.id_tv_coin_num?.setTextColor(mWhiteColor)
            holder.id_tv_day_seven_coins?.setTextColor(mWhiteColor)
        }else if(bean.status==0){
            holder.item_rl?.setBackgroundResource(R.drawable.shape_f0f0f0_r5)
            holder.id_img_days?.setImageResource(R.drawable.icon_jiaobiao_weiqiandao)
            holder.id_img_star_coin?.setImageResource(R.drawable.icon_xingbi_weiqiandao)
            holder.id_tv_coin_num?.setTextColor(mPaperColor)
            holder.id_tv_bottom_coin?.setTextColor(mBlackColor)
            holder.id_tv_day_seven_coins?.setTextColor(mPaperColor)
        }
        if(position<=5){
            holder.item_rl?.setLayoutParams(RelativeLayout.LayoutParams(Utils.dip2px(64), Utils.dip2px(82)))
            holder.id_tv_day_seven_coins?.visibility=View.GONE
        }else{
            holder.item_rl?.setLayoutParams(RelativeLayout.LayoutParams(Utils.dip2px(136), Utils.dip2px(82)))
            holder.id_tv_day_seven_coins?.visibility=View.VISIBLE
          //  holder.id_img_star_coin?.setImageResource(R.drawable.icon_day_seven_xingbi_weiqiandao)
            holder.id_tv_day_seven_coins?.text="x${bean.cash}"
        }

        holder.id_tv_days?.text=bean?.title
        holder.id_tv_coin_num?.text=bean.desc
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            LayoutInflater.from(AppContext.get())
                .inflate(R.layout.item_layout_sign, parent, false)
        )
    }

    class ViewHolder : RecyclerView.ViewHolder {
        var id_img_days: ImageView?
        var id_tv_days: TextView?
        var id_tv_bottom_coin: TextView?
        var id_tv_coin_num: TextView?
        var id_img_star_coin: ImageView?
        var item_rl: RelativeLayout?
        var id_tv_day_seven_coins:TextView?
        constructor(
            itemView: View
        ) : super(itemView) {
            id_img_days = itemView.findViewById<ImageView>(R.id.id_img_days)
            id_img_star_coin = itemView.findViewById<ImageView>(R.id.id_img_star_coin)
            id_tv_days = itemView.findViewById<TextView>(R.id.id_tv_days)
            id_tv_bottom_coin = itemView.findViewById<TextView>(R.id.id_tv_bottom_coin)
            id_tv_coin_num = itemView.findViewById<TextView>(R.id.id_tv_coin_num)
            id_tv_day_seven_coins = itemView.findViewById<TextView>(R.id.id_tv_day_seven_coins)
            item_rl = itemView.findViewById<RelativeLayout>(R.id.id_rl_item)


        }
    }
}