package com.google.ads.mediation; import android.content.Context; import android.os.Bundle; import android.view.View; import com.google.ads.mediation.admob.AdMobAdapter; import com.google.android.gms.ads.AdLoader; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.internal.client.zzay; import com.google.android.gms.ads.internal.client.zzdq; import com.google.android.gms.ads.interstitial.InterstitialAd; import com.google.android.gms.ads.mediation.MediationAdRequest; import com.google.android.gms.ads.mediation.MediationBannerAdapter; import com.google.android.gms.ads.mediation.MediationBannerListener; import com.google.android.gms.ads.mediation.MediationInterstitialAdapter; import com.google.android.gms.ads.mediation.MediationInterstitialListener; import com.google.android.gms.ads.mediation.MediationNativeAdapter; import com.google.android.gms.ads.mediation.MediationNativeListener; import com.google.android.gms.ads.mediation.NativeMediationAdRequest; import com.google.android.gms.ads.mediation.OnImmersiveModeUpdatedListener; import com.google.android.gms.ads.mediation.zza; import com.google.android.gms.internal.ads.zzbzk; import java.util.Date; import java.util.Iterator; import java.util.Set; /* loaded from: classes.dex */ public abstract class AbstractAdViewAdapter implements MediationBannerAdapter, MediationInterstitialAdapter, MediationNativeAdapter, OnImmersiveModeUpdatedListener, zza { public static final String AD_UNIT_ID_PARAMETER = "pubid"; private AdLoader adLoader; protected AdView mAdView; protected InterstitialAd mInterstitialAd; AdRequest buildAdRequest(Context context, MediationAdRequest mediationAdRequest, Bundle bundle, Bundle bundle2) { AdRequest.Builder builder = new AdRequest.Builder(); Date birthday = mediationAdRequest.getBirthday(); if (birthday != null) { builder.zzb(birthday); } int gender = mediationAdRequest.getGender(); if (gender != 0) { builder.zzc(gender); } Set keywords = mediationAdRequest.getKeywords(); if (keywords != null) { Iterator it = keywords.iterator(); while (it.hasNext()) { builder.addKeyword(it.next()); } } if (mediationAdRequest.isTesting()) { zzay.zzb(); builder.zza(zzbzk.zzy(context)); } if (mediationAdRequest.taggedForChildDirectedTreatment() != -1) { builder.zze(mediationAdRequest.taggedForChildDirectedTreatment() == 1); } builder.zzd(mediationAdRequest.isDesignedForFamilies()); builder.addNetworkExtrasBundle(AdMobAdapter.class, buildExtrasBundle(bundle, bundle2)); return builder.build(); } protected abstract Bundle buildExtrasBundle(Bundle bundle, Bundle bundle2); public String getAdUnitId(Bundle bundle) { return bundle.getString(AD_UNIT_ID_PARAMETER); } @Override // com.google.android.gms.ads.mediation.MediationBannerAdapter public View getBannerView() { return this.mAdView; } InterstitialAd getInterstitialAd() { return this.mInterstitialAd; } @Override // com.google.android.gms.ads.mediation.zza public zzdq getVideoController() { AdView adView = this.mAdView; if (adView != null) { return adView.zza().zza(); } return null; } AdLoader.Builder newAdLoader(Context context, String str) { return new AdLoader.Builder(context, str); } @Override // com.google.android.gms.ads.mediation.MediationAdapter public void onDestroy() { AdView adView = this.mAdView; if (adView != null) { adView.destroy(); this.mAdView = null; } if (this.mInterstitialAd != null) { this.mInterstitialAd = null; } if (this.adLoader != null) { this.adLoader = null; } } @Override // com.google.android.gms.ads.mediation.OnImmersiveModeUpdatedListener public void onImmersiveModeUpdated(boolean z10) { InterstitialAd interstitialAd = this.mInterstitialAd; if (interstitialAd != null) { interstitialAd.setImmersiveMode(z10); } } @Override // com.google.android.gms.ads.mediation.MediationAdapter public void onPause() { AdView adView = this.mAdView; if (adView != null) { adView.pause(); } } @Override // com.google.android.gms.ads.mediation.MediationAdapter public void onResume() { AdView adView = this.mAdView; if (adView != null) { adView.resume(); } } @Override // com.google.android.gms.ads.mediation.MediationBannerAdapter public void requestBannerAd(Context context, MediationBannerListener mediationBannerListener, Bundle bundle, AdSize adSize, MediationAdRequest mediationAdRequest, Bundle bundle2) { AdView adView = new AdView(context); this.mAdView = adView; adView.setAdSize(new AdSize(adSize.getWidth(), adSize.getHeight())); this.mAdView.setAdUnitId(getAdUnitId(bundle)); this.mAdView.setAdListener(new b(this, mediationBannerListener)); this.mAdView.loadAd(buildAdRequest(context, mediationAdRequest, bundle2, bundle)); } @Override // com.google.android.gms.ads.mediation.MediationInterstitialAdapter public void requestInterstitialAd(Context context, MediationInterstitialListener mediationInterstitialListener, Bundle bundle, MediationAdRequest mediationAdRequest, Bundle bundle2) { InterstitialAd.load(context, getAdUnitId(bundle), buildAdRequest(context, mediationAdRequest, bundle2, bundle), new c(this, mediationInterstitialListener)); } @Override // com.google.android.gms.ads.mediation.MediationNativeAdapter public void requestNativeAd(Context context, MediationNativeListener mediationNativeListener, Bundle bundle, NativeMediationAdRequest nativeMediationAdRequest, Bundle bundle2) { e eVar = new e(this, mediationNativeListener); AdLoader.Builder withAdListener = newAdLoader(context, bundle.getString(AD_UNIT_ID_PARAMETER)).withAdListener(eVar); withAdListener.withNativeAdOptions(nativeMediationAdRequest.getNativeAdOptions()); withAdListener.withNativeAdOptions(nativeMediationAdRequest.getNativeAdRequestOptions()); if (nativeMediationAdRequest.isUnifiedNativeAdRequested()) { withAdListener.forUnifiedNativeAd(eVar); } if (nativeMediationAdRequest.zzb()) { for (String str : nativeMediationAdRequest.zza().keySet()) { withAdListener.forCustomTemplateAd(str, eVar, true != ((Boolean) nativeMediationAdRequest.zza().get(str)).booleanValue() ? null : eVar); } } AdLoader build = withAdListener.build(); this.adLoader = build; build.loadAd(buildAdRequest(context, nativeMediationAdRequest, bundle2, bundle)); } @Override // com.google.android.gms.ads.mediation.MediationInterstitialAdapter public void showInterstitial() { InterstitialAd interstitialAd = this.mInterstitialAd; if (interstitialAd != null) { interstitialAd.show(null); } } }