package com.gh.gamecenter.amway.search

import android.content.Context
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.baselist.ListAdapter
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.feature.entity.GameEntity

class AmwaySearchAdapter(
    context: Context,
    val mViewModel: AmwaySearchViewModel,
    val mEntrance: String
) : ListAdapter<GameEntity>(context) {

    fun setData(listData: List<GameEntity>) {
        setListData(listData)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return AmwaySearchViewHolder(parent.toBinding(), mViewModel)
    }

    override fun getItemCount(): Int {
        return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        (holder as AmwaySearchViewHolder).bindView(mEntityList[position], mEntrance)
    }

}