package com.tgv.malware.ui.adapter

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