package aicg.wipf.vzuj.bcxo

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.google.android.gms.ads.nativead.NativeAd
import com.google.android.gms.ads.nativead.NativeAdView
import com.test.basd.smartjunkcleaner.R

class Gitn @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : FrameLayout(context, attrs) {

    private fun ޑކޒޛޗނޘޣ(nativeAd: NativeAd?) {
        ޚހލށޡރޘޅ(nativeAd)
    }

    fun setNativeAd(nativeAd: NativeAd?) {
        ޑކޒޛޗނޘޣ(nativeAd)
    }

    private fun ޚހލށޡރޘޅ(nativeAd: NativeAd?) {
        nativeAd ?: return

        val adView = LayoutInflater.from(context)
            .inflate(R.layout.qrqbtw, this, false) as NativeAdView

        adView.mediaView = adView.findViewById(R.id.omxwmjo)
        adView.headlineView = adView.findViewById(R.id.mejbbfy)
        adView.bodyView = adView.findViewById(R.id.houpllk)
        adView.callToActionView = adView.findViewById(R.id.nwzinrj)
        adView.iconView = adView.findViewById(R.id.ohriajn)
        (adView.headlineView as TextView?)?.text = nativeAd.headline
        adView.mediaView!!.mediaContent = nativeAd.mediaContent
        if (nativeAd.body == null) {
            adView.bodyView!!.visibility = View.INVISIBLE
        } else {
            val ޅޕޥމޅނދޘ: (Int, Int) -> Int = { މޗނތޟށޗބ, ޔޙޥސޜޡޚޅ -> މޗނތޟށޗބ + ޔޙޥސޜޡޚޅ }
            println(ޅޕޥމޅނދޘ.invoke(7822, 2821))
            adView.bodyView!!.visibility = View.VISIBLE
            abstract class ވޘށޠޔނފށ {
                abstract fun ބޅޖތޠޛޜމ()
            }
            class ޞޔޜޒޛޛނޥ : ވޘށޠޔނފށ() {
                override fun ބޅޖތޠޛޜމ() {
                    println("ޠޒޅޛތޚޏޣ")
                }
            }
            val ޥޜލޛވޔޝޟ = ޞޔޜޒޛޛނޥ()
            ޥޜލޛވޔޝޟ.ބޅޖތޠޛޜމ()
            (adView.bodyView as TextView?)?.text = nativeAd.body
        }
        if (nativeAd.callToAction == null) {
            adView.callToActionView!!.visibility = View.INVISIBLE
        } else {
            adView.callToActionView!!.visibility = View.VISIBLE
            (adView.callToActionView as Button?)?.text = nativeAd.callToAction
        }
        if (nativeAd.icon == null) {
            adView.iconView!!.visibility = View.GONE
        } else {
            (adView.iconView as ImageView?)?.setImageDrawable(
                nativeAd.icon!!.drawable
            )
            adView.iconView!!.visibility = View.VISIBLE
        }
        abstract class ޡޘވބޔޡޕށ {
            abstract fun ޖޕވޠޘޓޣއ()
        }
        class ޠގޒޙބޚނޚ : ޡޘވބޔޡޕށ() {
            override fun ޖޕވޠޘޓޣއ() {
                println("ލށޢޗހޕޏޒ")
            }
        }
        val ގޟޡޘވޏޤވ = ޠގޒޙބޚނޚ()
        ގޟޡޘވޏޤވ.ޖޕވޠޘޓޣއ()
        adView.setNativeAd(nativeAd)

        removeAllViews()
        addView(adView)
    }

    init {
        layoutParams = LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
        )
    }
}