package xn.hxp.ui.adapter

import android.content.Context
import android.graphics.Color
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import xn.hxp.R
import com.rc.httpcore.bean.EarlyWarningListBean

class WarningEventsAdapter(private var ct: Context) :
    BaseQuickAdapter<EarlyWarningListBean, BaseViewHolder>(R.layout.item_warning_notice) {

    init {
        addChildClickViewIds(R.id.operate)
    }

    override fun convert(holder: BaseViewHolder, item: EarlyWarningListBean) {
        holder.setText(R.id.warnTime, "${item.warnTime}")
        holder.setText(R.id.warnContent, "${item.warnContent}")
//        var noView = holder.getView<TextView>(R.id.noticeStatus)

        //1  已处理     0 待处理（可以手动处理）  2 待处理（不可手动处理  显示详情）
        when (item.noticeStatus) {

            1 -> {
//                noView.text = "已处理"
//                noView.setTextColor(ContextCompat.getColor(ct, R.color.black))
                holder.setText(R.id.operate, "详情")
                item.solve = false
            }

            0 -> {
//                noView.text = "待处理"
                if (item.isHandlePeople) {
//                    noView.setTextColor(ContextCompat.getColor(ct, R.color.purple_FFFF8C11))
                    holder.setText(R.id.operate, "处理")
                    holder.setTextColor(R.id.operate, Color.parseColor("#FFFF8C11"))
                    item.solve = false
                } else {
//                    noView.setTextColor(ContextCompat.getColor(ct, R.color.black))
                    holder.setText(R.id.operate, "详情")
                    item.solve = true
                }
            }

            2 -> {
//                noView.text = "待处理"
//                noView.setTextColor(ContextCompat.getColor(ct, R.color.black))
                holder.setText(R.id.operate, "详情")
                item.solve = false
            }

            else -> {
//                noView.text = "待处理"
//                noView.setTextColor(ContextCompat.getColor(ct, R.color.black))
                holder.setText(R.id.operate, "详情")
                item.solve = false
            }

        }
    }
}