package com.develop.main.init.ui.provider


import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.develop.food.base.data.model.HomeBannerListModel
import com.develop.food.base.data.model.HomeBannerModel
import com.develop.main.R
import com.develop.main.init.ui.adapter.HomeBannerAdapter
import com.develop.main.init.ui.adapter.RecipesMainAdapter
import com.youth.banner.Banner

class HomeBannerProvider : BaseItemProvider<Any>() {
    override val itemViewType: Int
        get() = RecipesMainAdapter.BANNER_TAG
    override val layoutId: Int
        get() = R.layout.home_banner_provider

    var onBannerItemClickListener: OnBannerItemClickListener? = null
    override fun convert(helper: BaseViewHolder, item: Any) {
        item as HomeBannerListModel
       val bannerAdapter = HomeBannerAdapter(item.data)
        bannerAdapter.onBannerItemClickListener = object :HomeBannerAdapter.OnBannerItemClickListener{
            override fun onNetRecipesClick(bannerModel: HomeBannerModel) {
                onBannerItemClickListener?.onNetRecipesClick(bannerModel)
            }
        }
        helper.getView<Banner<*, *>>(R.id.home_banner_view).adapter = bannerAdapter
    }

    interface OnBannerItemClickListener {
        fun onNetRecipesClick(bannerModel: HomeBannerModel)
    }
}