package com.gh.gamecenter.home.custom.adapter

import android.content.Context
import android.view.ViewGroup
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.entity.RecommendLabel
import com.gh.gamecenter.feature.entity.PageLocation
import com.gh.gamecenter.home.custom.viewholder.CustomHomeGameTestV2RecommendViewHolder

/**
 * @author : liujiarui
 * date : 2023/3/6
 * description : 新游开测，推荐标签
 */
class CustomHomeGameTestV2RecommendRvAdapter(
    context: Context,
    private val linkText: String,
    private val pageLocation: PageLocation,
) : CustomBaseChildAdapter<RecommendLabel, CustomHomeGameTestV2RecommendViewHolder>(context) {

    override fun getKey(t: RecommendLabel): String {
        return t.id
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomHomeGameTestV2RecommendViewHolder {
        return CustomHomeGameTestV2RecommendViewHolder(parent.toBinding())
    }

    override fun onBindViewHolder(holder: CustomHomeGameTestV2RecommendViewHolder, position: Int) {
        val label = dataList.getOrElse(position) { RecommendLabel() }
        holder.bind(label, linkText, pageLocation)
    }

}