package com.rgt.superr.ui.adapter

import android.content.Context
import android.view.ViewGroup
import com.rgt.superr.R
import com.rgt.superr.business.ads.AdsMgr
import com.rgt.superr.business.ads.NativeParentView
import com.rgt.superr.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))
    }
}