package com.cheng.blzb.ui.fragment.push.subscribe.source

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cheng.blzb.R
import com.cheng.blzb.bean.SourceEntity

class RecommendSourceAdapter: BaseQuickAdapter<SourceEntity, BaseViewHolder>(R.layout.listitem_recommend_source) {
    override fun convert(holder: BaseViewHolder, item: SourceEntity) {
        holder.setText(R.id.tv_name, item.name)
        when(holder.layoutPosition) {
            0 -> {
                holder.setImageResource(R.id.iv_tag1, R.mipmap.ic_recommend_source_tag1)
                holder.setVisible(R.id.iv_tag1, true)
                holder.setVisible(R.id.iv_tag2, true)
                holder.setGone(R.id.tv_index, true)
            }
            1 -> {
                holder.setImageResource(R.id.iv_tag1, R.mipmap.ic_recommend_source_tag2)
                holder.setVisible(R.id.iv_tag1, true)
                holder.setVisible(R.id.iv_tag2, true)
                holder.setGone(R.id.tv_index, true)
            }
            2 -> {
                holder.setImageResource(R.id.iv_tag1, R.mipmap.ic_recommend_source_tag3)
                holder.setVisible(R.id.iv_tag1, true)
                holder.setVisible(R.id.iv_tag2, true)
                holder.setGone(R.id.tv_index, true)
            }
            else -> {
                holder.setText(R.id.tv_index, "${holder.layoutPosition + 1}")
                holder.setVisible(R.id.tv_index, true)
                holder.setGone(R.id.iv_tag1, true)
                holder.setVisible(R.id.iv_tag2, false)
            }
        }
    }
}