package com.gh.gamecenter.game.rank

import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.databinding.RankCollectionListBinding
import com.gh.gamecenter.entity.SubjectEntity

/**
 * 排行榜
 */
class RankCollectionViewHolder(val binding: RankCollectionListBinding) : BaseRecyclerViewHolder<Any>(binding.root) {

    fun bindRankCollection(collection: SubjectEntity, clickClosure: (SubjectEntity, Int) -> Unit): RankCollectionAdapter {
        binding.recyclerView.apply {
            isNestedScrollingEnabled = false
            if (adapter is RankCollectionAdapter) {
                (adapter as RankCollectionAdapter).checkResetData(collection)
            } else {
                layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
                adapter = RankCollectionAdapter(context, collection, clickClosure)
            }
            return adapter as RankCollectionAdapter
        }
    }
}