package com.zj365.health.adapter

import android.graphics.Typeface
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.util.SpannableUtils
import com.zj365.health.R
import com.zj365.health.model.SleepIntroBean

class SleepIntroAdapter : BaseAdapter<SleepIntroBean>(R.layout.sleep_intro_item) {

    override fun convert(holder: BaseViewHolder, item: SleepIntroBean) {
        holder.setText(R.id.mTitle, item.title)
            .setText(R.id.mIntro, item.intro)
            .setText(R.id.mStatus, SpannableUtils.setStrSpan(item.statu, -1, getColor(item.statu), Typeface.NORMAL,0, item.statu.length))
    }


    private fun getColor(statu: String): Int{
        return ContextCompat.getColor(
            context, when (statu) {
                "正常" -> {
                    R.color.col_9BDd
                }

                "偏高" -> {
                    R.color.col_FDA481
                }

                "偏低" -> {
                    R.color.col_9BD
                }
                else -> {
                    R.color.black
                }
            }
        )
    }
}