package com.easy.clean.ui.adapter

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