package com.cheng.blzb.ui.fragment.home.qyzc

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cheng.blzb.R
import com.example.base.utils.DensityUtils

class QYZCCompanyAdapter(val context: Context, val data: MutableList<String>): RecyclerView.Adapter<BaseViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
        val view = View.inflate(context, R.layout.listitem_qyzc_company, null)
        val lp = ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DensityUtils.dp2px(22f))
        lp.leftMargin = DensityUtils.dp2px(13f)
        view.layoutParams = lp
        return BaseViewHolder(view)
    }

    @SuppressLint("DiscouragedApi")
    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        holder.setText(R.id.tv_name, data[position % data.size])
    }

    override fun getItemCount(): Int {
        return if (data.isNotEmpty()) Int.MAX_VALUE else 0
    }

    companion object {
        fun getList(): List<String> {
            return listOf(
                "重庆做梦**科技有限公司",
                "重庆荣科**科技有限公司",
                "重庆高新**科技有限公司",
                "重庆中天**科技有限公司",
                "重庆太仓**科技有限公司",
                "重庆云维**科技有限公司",
                "重庆若晴**科技有限公司",
                "重庆东方**科技有限公司"
            )
        }
    }
}