package com.zj365.mime.adapter

import android.text.Html
import android.widget.ImageView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.setImage
import com.xty.common.setRoundImage
import com.zj365.mime.BuildConfig
import com.zj365.mime.R
import com.xty.network.model.ProgrammeBean

class ProgrammeAdapter:BaseAdapter<ProgrammeBean>(R.layout.item_programme) {
    override fun convert(holder: BaseViewHolder, item: ProgrammeBean) {
        holder.setText(R.id.programeName,item.name)
            .setText(R.id.mTime,item.createTime)
            .setText(R.id.agencyName,item.orgName)
            .setText(R.id.content,  Html.fromHtml(item.prName))
        item.imageUrl?.let {
            if (it.contains("http")) {
                holder.getView<ImageView>(R.id.logo).setRoundImage(context, item.imageUrl)
            } else {
                holder.getView<ImageView>(R.id.logo)
                    .setRoundImage(context, BuildConfig.url + item.imageUrl)
            }
        }
    }
}