package com.google.android.gms.ads; import android.content.Context; import android.os.RemoteException; import com.google.android.gms.ads.admanager.AdManagerAdRequest; import com.google.android.gms.ads.formats.AdManagerAdViewOptions; import com.google.android.gms.ads.formats.NativeAdOptions; import com.google.android.gms.ads.formats.NativeCustomTemplateAd; import com.google.android.gms.ads.formats.OnAdManagerAdViewLoadedListener; import com.google.android.gms.ads.formats.UnifiedNativeAd; import com.google.android.gms.ads.internal.client.zzay; import com.google.android.gms.ads.internal.client.zzba; import com.google.android.gms.ads.internal.client.zzbn; import com.google.android.gms.ads.internal.client.zzbq; import com.google.android.gms.ads.internal.client.zzdx; import com.google.android.gms.ads.internal.client.zzeu; import com.google.android.gms.ads.internal.client.zzfl; import com.google.android.gms.ads.internal.client.zzp; import com.google.android.gms.ads.internal.client.zzq; import com.google.android.gms.ads.nativead.NativeAd; import com.google.android.gms.ads.nativead.NativeCustomFormatAd; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.internal.ads.zzbbm; import com.google.android.gms.internal.ads.zzbdd; import com.google.android.gms.internal.ads.zzbef; import com.google.android.gms.internal.ads.zzbgw; import com.google.android.gms.internal.ads.zzbgy; import com.google.android.gms.internal.ads.zzbgz; import com.google.android.gms.internal.ads.zzbnt; import com.google.android.gms.internal.ads.zzbrg; import com.google.android.gms.internal.ads.zzbri; import com.google.android.gms.internal.ads.zzbzg; import com.google.android.gms.internal.ads.zzbzr; /* loaded from: classes.dex */ public class AdLoader { private final zzp zza; private final Context zzb; private final zzbn zzc; AdLoader(Context context, zzbn zzbnVar, zzp zzpVar) { this.zzb = context; this.zzc = zzbnVar; this.zza = zzpVar; } private final void zzb(final zzdx zzdxVar) { zzbbm.zza(this.zzb); if (((Boolean) zzbdd.zzc.zze()).booleanValue()) { if (((Boolean) zzba.zzc().zzb(zzbbm.zzjJ)).booleanValue()) { zzbzg.zzb.execute(new Runnable() { // from class: com.google.android.gms.ads.zza @Override // java.lang.Runnable public final void run() { AdLoader.this.zza(zzdxVar); } }); return; } } try { this.zzc.zzg(this.zza.zza(this.zzb, zzdxVar)); } catch (RemoteException e10) { zzbzr.zzh("Failed to load ad.", e10); } } public boolean isLoading() { try { return this.zzc.zzi(); } catch (RemoteException e10) { zzbzr.zzk("Failed to check if ad is loading.", e10); return false; } } public void loadAd(AdRequest adRequest) { zzb(adRequest.zza); } public void loadAds(AdRequest adRequest, int i10) { try { this.zzc.zzh(this.zza.zza(this.zzb, adRequest.zza), i10); } catch (RemoteException e10) { zzbzr.zzh("Failed to load ads.", e10); } } final /* synthetic */ void zza(zzdx zzdxVar) { try { this.zzc.zzg(this.zza.zza(this.zzb, zzdxVar)); } catch (RemoteException e10) { zzbzr.zzh("Failed to load ad.", e10); } } public static class Builder { private final Context zza; private final zzbq zzb; public Builder(Context context, String str) { Context context2 = (Context) Preconditions.checkNotNull(context, "context cannot be null"); zzbq zzc = zzay.zza().zzc(context, str, new zzbnt()); this.zza = context2; this.zzb = zzc; } public AdLoader build() { try { return new AdLoader(this.zza, this.zzb.zze(), zzp.zza); } catch (RemoteException e10) { zzbzr.zzh("Failed to build AdLoader.", e10); return new AdLoader(this.zza, new zzeu().zzc(), zzp.zza); } } public Builder forAdManagerAdView(OnAdManagerAdViewLoadedListener onAdManagerAdViewLoadedListener, AdSize... adSizeArr) { if (adSizeArr == null || adSizeArr.length <= 0) { throw new IllegalArgumentException("The supported ad sizes must contain at least one valid ad size."); } try { this.zzb.zzj(new zzbgy(onAdManagerAdViewLoadedListener), new zzq(this.zza, adSizeArr)); } catch (RemoteException e10) { zzbzr.zzk("Failed to add Google Ad Manager banner ad listener", e10); } return this; } public Builder forCustomFormatAd(String str, NativeCustomFormatAd.OnCustomFormatAdLoadedListener onCustomFormatAdLoadedListener, NativeCustomFormatAd.OnCustomClickListener onCustomClickListener) { zzbrg zzbrgVar = new zzbrg(onCustomFormatAdLoadedListener, onCustomClickListener); try { this.zzb.zzh(str, zzbrgVar.zzb(), zzbrgVar.zza()); } catch (RemoteException e10) { zzbzr.zzk("Failed to add custom format ad listener", e10); } return this; } @Deprecated public Builder forCustomTemplateAd(String str, NativeCustomTemplateAd.OnCustomTemplateAdLoadedListener onCustomTemplateAdLoadedListener, NativeCustomTemplateAd.OnCustomClickListener onCustomClickListener) { zzbgw zzbgwVar = new zzbgw(onCustomTemplateAdLoadedListener, onCustomClickListener); try { this.zzb.zzh(str, zzbgwVar.zze(), zzbgwVar.zzd()); } catch (RemoteException e10) { zzbzr.zzk("Failed to add custom template ad listener", e10); } return this; } public Builder forNativeAd(NativeAd.OnNativeAdLoadedListener onNativeAdLoadedListener) { try { this.zzb.zzk(new zzbri(onNativeAdLoadedListener)); } catch (RemoteException e10) { zzbzr.zzk("Failed to add google native ad listener", e10); } return this; } @Deprecated public Builder forUnifiedNativeAd(UnifiedNativeAd.OnUnifiedNativeAdLoadedListener onUnifiedNativeAdLoadedListener) { try { this.zzb.zzk(new zzbgz(onUnifiedNativeAdLoadedListener)); } catch (RemoteException e10) { zzbzr.zzk("Failed to add google native ad listener", e10); } return this; } public Builder withAdListener(AdListener adListener) { try { this.zzb.zzl(new com.google.android.gms.ads.internal.client.zzg(adListener)); } catch (RemoteException e10) { zzbzr.zzk("Failed to set AdListener.", e10); } return this; } public Builder withAdManagerAdViewOptions(AdManagerAdViewOptions adManagerAdViewOptions) { try { this.zzb.zzm(adManagerAdViewOptions); } catch (RemoteException e10) { zzbzr.zzk("Failed to specify Ad Manager banner ad options", e10); } return this; } @Deprecated public Builder withNativeAdOptions(NativeAdOptions nativeAdOptions) { try { this.zzb.zzo(new zzbef(nativeAdOptions)); } catch (RemoteException e10) { zzbzr.zzk("Failed to specify native ad options", e10); } return this; } public Builder withNativeAdOptions(com.google.android.gms.ads.nativead.NativeAdOptions nativeAdOptions) { try { this.zzb.zzo(new zzbef(4, nativeAdOptions.shouldReturnUrlsForImageAssets(), -1, nativeAdOptions.shouldRequestMultipleImages(), nativeAdOptions.getAdChoicesPlacement(), nativeAdOptions.getVideoOptions() != null ? new zzfl(nativeAdOptions.getVideoOptions()) : null, nativeAdOptions.zzc(), nativeAdOptions.getMediaAspectRatio(), nativeAdOptions.zza(), nativeAdOptions.zzb())); } catch (RemoteException e10) { zzbzr.zzk("Failed to specify native ad options", e10); } return this; } } public void loadAd(AdManagerAdRequest adManagerAdRequest) { zzb(adManagerAdRequest.zza); } }