package com.base.appzxhy.ui.adapter

import android.content.Context
import android.view.ViewGroup
import com.base.appzxhy.R
import com.base.appzxhy.business.ads.AdsMgr
import com.base.appzxhy.business.ads.NativeParentView
import com.base.appzxhy.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter

class AdAdapter(
    val layout: Int
) : BaseQuickAdapter<Any, CommonViewHolder>() {

    override fun onBindViewHolder(holder: CommonViewHolder, position: Int, item: Any?) {

        item ?: return
        val flAd: NativeParentView? = holder.itemView.findViewById(R.id.flAd)

        flAd?.let {
            AdsMgr.showNative(it, R.layout.layout_admob_native_custom)
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): CommonViewHolder {
        return CommonViewHolder(layout.inflate(parent))
    }
}