package com.zj365.health.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.DkBean

class DkAdapter : BaseAdapter<DkBean.ClockIn>(R.layout.item_dk) {
    val imageIds by lazy {
        arrayOf(
            R.mipmap.ic_get_bad,
            R.mipmap.ic_drank,
            R.mipmap.ic_eat,
            R.mipmap.ic_walk,
            R.mipmap.ic_breath,
            R.mipmap.ic_sleep
        )
    }

    val arrays by lazy { context.resources.getStringArray(R.array.dk_info) }
    override fun convert(holder: BaseViewHolder, item: DkBean.ClockIn) {
        holder.setImageResource(R.id.mImage, imageIds[holder.layoutPosition])
            .setText(R.id.mInfo, arrays[holder.layoutPosition])
        var view = holder.getView<TextView>(R.id.mTvStatus)
        view.isSelected = item.isSelect
        holder.setText(R.id.mTvStatus,if(view.isSelected) R.string.mine_dk_end else R.string.mine_dk)
        if (getItemPosition(item)==imageIds.size-1) {
            holder.getView<View>(R.id.line).visibility = View.GONE
        }else{
            holder.getView<View>(R.id.line).visibility = View.VISIBLE
        }

    }
}