package com.applovin.impl; import android.app.Activity; import android.content.DialogInterface; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RectShape; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.amazon.device.ads.AdError; import com.amazon.device.ads.DTBAdResponse; import com.applovin.impl.ec; import com.applovin.impl.mediation.debugger.ui.testmode.AdControlButton; import com.applovin.impl.o0; import com.applovin.impl.r; import com.applovin.impl.y; import com.applovin.mediation.MaxAd; import com.applovin.mediation.MaxAdFormat; import com.applovin.mediation.MaxAdRevenueListener; import com.applovin.mediation.MaxAdViewAdListener; import com.applovin.mediation.MaxDebuggerAdUnitDetailActivity; import com.applovin.mediation.MaxError; import com.applovin.mediation.MaxReward; import com.applovin.mediation.MaxRewardedAdListener; import com.applovin.mediation.ads.MaxAdView; import com.applovin.mediation.ads.MaxAppOpenAd; import com.applovin.mediation.ads.MaxInterstitialAd; import com.applovin.mediation.ads.MaxRewardedAd; import com.applovin.mediation.ads.MaxRewardedInterstitialAd; import com.applovin.mediation.nativeAds.MaxNativeAdListener; import com.applovin.mediation.nativeAds.MaxNativeAdLoader; import com.applovin.mediation.nativeAds.MaxNativeAdView; import com.applovin.sdk.AppLovinSdkUtils; import com.applovin.sdk.R; import com.ironsource.bt; import java.util.List; /* loaded from: classes.dex */ public abstract class x extends se implements AdControlButton.a, MaxRewardedAdListener, MaxAdViewAdListener, MaxAdRevenueListener, o0.a { private com.applovin.impl.sdk.j a; private z b; private ir c; private y d; private MaxAdView f; private MaxInterstitialAd g; private MaxAppOpenAd h; private MaxRewardedInterstitialAd i; private MaxRewardedAd j; private MaxNativeAdView k; private MaxNativeAdLoader l; private MaxAd m; private d0 n; private List o; private ListView p; private View q; private AdControlButton r; private TextView s; private o0 t; /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(DialogInterface dialogInterface) { this.n = null; } @Override // com.applovin.impl.se public com.applovin.impl.sdk.j getSdk() { return this.a; } @Override // com.applovin.mediation.MaxAdListener public void onAdClicked(@NonNull MaxAd maxAd) { yp.a(bt.f, maxAd, this); } @Override // com.applovin.mediation.MaxAdViewAdListener public void onAdCollapsed(@NonNull MaxAd maxAd) { yp.a("onAdCollapsed", maxAd, this); } @Override // com.applovin.mediation.MaxAdListener public void onAdDisplayed(@NonNull MaxAd maxAd) { yp.a("onAdDisplayed", maxAd, this); } @Override // com.applovin.mediation.MaxAdViewAdListener public void onAdExpanded(@NonNull MaxAd maxAd) { yp.a("onAdExpanded", maxAd, this); } @Override // com.applovin.mediation.MaxAdListener public void onAdHidden(@NonNull MaxAd maxAd) { yp.a("onAdHidden", maxAd, this); } @Override // com.applovin.mediation.MaxAdRevenueListener public void onAdRevenuePaid(@NonNull MaxAd maxAd) { yp.a("onAdRevenuePaid", maxAd, this); } @Override // com.applovin.mediation.MaxRewardedAdListener public void onUserRewarded(@NonNull MaxAd maxAd, @NonNull MaxReward maxReward) { yp.a("onUserRewarded", maxAd, this); } public void initialize(final z zVar, @Nullable final a0 a0Var, @Nullable ir irVar, final com.applovin.impl.sdk.j jVar) { List a2; this.a = jVar; this.b = zVar; this.c = irVar; this.o = jVar.l0().b(); y yVar = new y(zVar, a0Var, irVar, this); this.d = yVar; yVar.a(new ec.a() { // from class: com.applovin.impl.x$$ExternalSyntheticLambda2 @Override // com.applovin.impl.ec.a public final void a(lb lbVar, dc dcVar) { x.this.a(jVar, zVar, a0Var, lbVar, dcVar); } }); b(); if (zVar.f().f()) { if ((irVar != null && !irVar.b().d().B()) || (a2 = jVar.N().a(zVar.c())) == null || a2.isEmpty()) { return; } this.t = new o0(a2, zVar.a(), this); } } @Override // com.applovin.impl.se, android.app.Activity public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.mediation_debugger_ad_unit_detail_activity); setTitle(this.d.k()); this.p = (ListView) findViewById(R.id.listView); this.q = findViewById(R.id.ad_presenter_view); this.r = (AdControlButton) findViewById(R.id.ad_control_button); this.s = (TextView) findViewById(R.id.status_textview); this.p.setAdapter((ListAdapter) this.d); this.s.setText(a()); this.s.setTypeface(Typeface.DEFAULT_BOLD); this.r.setOnClickListener(this); ShapeDrawable shapeDrawable = new ShapeDrawable(); shapeDrawable.setPadding(0, 10, 0, 0); shapeDrawable.getPaint().setColor(-1); shapeDrawable.getPaint().setShadowLayer(10, 0.0f, -10, 855638016); shapeDrawable.setShape(new RectShape()); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{shapeDrawable}); layerDrawable.setLayerInset(0, 0, 10, 0, 0); this.q.setBackground(layerDrawable); } @Override // com.applovin.impl.se, android.app.Activity public void onDestroy() { MaxAd maxAd; super.onDestroy(); if (this.c != null) { this.a.l0().a(this.o); } MaxAdView maxAdView = this.f; if (maxAdView != null) { maxAdView.destroy(); } MaxInterstitialAd maxInterstitialAd = this.g; if (maxInterstitialAd != null) { maxInterstitialAd.destroy(); } MaxAppOpenAd maxAppOpenAd = this.h; if (maxAppOpenAd != null) { maxAppOpenAd.destroy(); } MaxRewardedInterstitialAd maxRewardedInterstitialAd = this.i; if (maxRewardedInterstitialAd != null) { maxRewardedInterstitialAd.destroy(); } MaxRewardedAd maxRewardedAd = this.j; if (maxRewardedAd != null) { maxRewardedAd.destroy(); } MaxNativeAdLoader maxNativeAdLoader = this.l; if (maxNativeAdLoader == null || (maxAd = this.m) == null) { return; } maxNativeAdLoader.destroy(maxAd); } public class a extends MaxNativeAdListener { public a() { } @Override // com.applovin.mediation.nativeAds.MaxNativeAdListener public void onNativeAdLoaded(MaxNativeAdView maxNativeAdView, MaxAd maxAd) { if (x.this.m != null) { x.this.l.destroy(x.this.m); } x.this.m = maxAd; if (maxNativeAdView == null) { x xVar = x.this; com.applovin.impl.sdk.j unused = x.this.a; xVar.k = new MaxNativeAdView(MaxNativeAdView.MEDIUM_TEMPLATE_1, com.applovin.impl.sdk.j.l()); x.this.l.render(x.this.k, maxAd); } else { x.this.k = maxNativeAdView; } x.this.onAdLoaded(maxAd); } @Override // com.applovin.mediation.nativeAds.MaxNativeAdListener public void onNativeAdLoadFailed(String str, MaxError maxError) { x.this.onAdLoadFailed(str, maxError); } @Override // com.applovin.mediation.nativeAds.MaxNativeAdListener public void onNativeAdClicked(MaxAd maxAd) { x.this.onAdClicked(maxAd); } } private void b() { String c = this.b.c(); if (this.b.a().isAdViewAd()) { MaxAdView maxAdView = new MaxAdView(c, this.b.a(), this.a.s0(), this); this.f = maxAdView; maxAdView.setExtraParameter("adaptive_banner", "false"); this.f.setExtraParameter("disable_auto_retries", "true"); this.f.setExtraParameter("disable_precache", "true"); this.f.setExtraParameter("allow_pause_auto_refresh_immediately", "true"); this.f.stopAutoRefresh(); this.f.setListener(this); return; } if (MaxAdFormat.INTERSTITIAL == this.b.a()) { MaxInterstitialAd maxInterstitialAd = new MaxInterstitialAd(c, this.a.s0(), this); this.g = maxInterstitialAd; maxInterstitialAd.setExtraParameter("disable_auto_retries", "true"); this.g.setListener(this); return; } if (MaxAdFormat.APP_OPEN == this.b.a()) { MaxAppOpenAd maxAppOpenAd = new MaxAppOpenAd(c, this.a.s0()); this.h = maxAppOpenAd; maxAppOpenAd.setExtraParameter("disable_auto_retries", "true"); this.h.setListener(this); return; } if (MaxAdFormat.REWARDED_INTERSTITIAL == this.b.a()) { MaxRewardedInterstitialAd maxRewardedInterstitialAd = new MaxRewardedInterstitialAd(c, this.a.s0(), this); this.i = maxRewardedInterstitialAd; maxRewardedInterstitialAd.setExtraParameter("disable_auto_retries", "true"); this.i.setListener(this); return; } if (MaxAdFormat.REWARDED == this.b.a()) { MaxRewardedAd maxRewardedAd = MaxRewardedAd.getInstance(c, this.a.s0(), this); this.j = maxRewardedAd; maxRewardedAd.setExtraParameter("disable_auto_retries", "true"); this.j.setListener(this); return; } if (MaxAdFormat.NATIVE == this.b.a()) { MaxNativeAdLoader maxNativeAdLoader = new MaxNativeAdLoader(c, this.a.s0(), this); this.l = maxNativeAdLoader; maxNativeAdLoader.setExtraParameter("disable_auto_retries", "true"); this.l.setNativeAdListener(new a()); this.l.setRevenueListener(this); } } @Override // com.applovin.impl.mediation.debugger.ui.testmode.AdControlButton.a public void onClick(AdControlButton adControlButton) { if (this.a.l0().c()) { yp.a("Not Supported", "Ad loads are not supported while Test Mode is enabled. Please restart the app.", this); return; } if (this.d.j() != this.b.f()) { yp.a("Not Supported", "You cannot load an ad from this waterfall because it does not target the current device. To load an ad, please select the targeted waterfall.", this); return; } MaxAdFormat a2 = this.b.a(); AdControlButton.b bVar = AdControlButton.b.LOAD; if (bVar == adControlButton.getControlState()) { adControlButton.setControlState(AdControlButton.b.LOADING); o0 o0Var = this.t; if (o0Var != null) { o0Var.a(); return; } else { a(a2); return; } } if (AdControlButton.b.SHOW == adControlButton.getControlState()) { if (!a2.isAdViewAd() && a2 != MaxAdFormat.NATIVE) { adControlButton.setControlState(bVar); } b(a2); } } @Override // com.applovin.mediation.MaxAdListener public void onAdLoaded(@NonNull MaxAd maxAd) { this.s.setText(maxAd.getNetworkName() + " ad loaded"); this.r.setControlState(AdControlButton.b.SHOW); if (maxAd.getFormat().isAdViewAd()) { a(this.f, maxAd.getFormat().getSize()); } else if (MaxAdFormat.NATIVE == this.b.a()) { a(this.k, MaxAdFormat.MREC.getSize()); } } @Override // com.applovin.mediation.MaxAdListener public void onAdDisplayFailed(MaxAd maxAd, MaxError maxError) { this.r.setControlState(AdControlButton.b.LOAD); this.s.setText(""); yp.a("Failed to display " + maxAd.getFormat().getDisplayName(), "MAX Error\nCode: " + maxError.getCode() + "\nMessage: " + maxError.getMessage() + "\n\n" + maxAd.getNetworkName() + " Display Error\nCode: " + maxError.getMediatedNetworkErrorCode() + "\nMessage: " + maxError.getMediatedNetworkErrorMessage(), this); } @Override // com.applovin.impl.o0.a public void onAdResponseLoaded(DTBAdResponse dTBAdResponse, MaxAdFormat maxAdFormat) { if (maxAdFormat.isAdViewAd()) { this.f.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } else if (MaxAdFormat.INTERSTITIAL == maxAdFormat) { this.g.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } else if (MaxAdFormat.APP_OPEN == maxAdFormat) { this.h.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } else if (MaxAdFormat.REWARDED_INTERSTITIAL == maxAdFormat) { this.i.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } else if (MaxAdFormat.REWARDED == maxAdFormat) { this.j.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } else if (MaxAdFormat.NATIVE == maxAdFormat) { this.l.setLocalExtraParameter("amazon_ad_response", dTBAdResponse); } a(maxAdFormat); } @Override // com.applovin.impl.o0.a public void onAdLoadFailed(AdError adError, MaxAdFormat maxAdFormat) { if (maxAdFormat.isAdViewAd()) { this.f.setLocalExtraParameter("amazon_ad_error", adError); } else if (MaxAdFormat.INTERSTITIAL == maxAdFormat) { this.g.setLocalExtraParameter("amazon_ad_error", adError); } else if (MaxAdFormat.APP_OPEN == maxAdFormat) { this.h.setLocalExtraParameter("amazon_ad_error", adError); } else if (MaxAdFormat.REWARDED_INTERSTITIAL == maxAdFormat) { this.i.setLocalExtraParameter("amazon_ad_error", adError); } else if (MaxAdFormat.REWARDED == maxAdFormat) { this.j.setLocalExtraParameter("amazon_ad_error", adError); } else if (MaxAdFormat.NATIVE == maxAdFormat) { this.l.setLocalExtraParameter("amazon_ad_error", adError); } a(maxAdFormat); } private void b(MaxAdFormat maxAdFormat) { if (maxAdFormat.isAdViewAd()) { a(this.f, maxAdFormat.getSize()); return; } if (MaxAdFormat.INTERSTITIAL == this.b.a()) { this.g.showAd("[Mediation Debugger Live Ad]"); return; } if (MaxAdFormat.APP_OPEN == this.b.a()) { this.h.showAd("[Mediation Debugger Live Ad]"); return; } if (MaxAdFormat.REWARDED_INTERSTITIAL == this.b.a()) { this.i.showAd("[Mediation Debugger Live Ad]"); } else if (MaxAdFormat.REWARDED == this.b.a()) { this.j.showAd("[Mediation Debugger Live Ad]"); } else if (MaxAdFormat.NATIVE == this.b.a()) { a(this.k, MaxAdFormat.MREC.getSize()); } } private String a() { return this.a.l0().c() ? "Not supported while Test Mode is enabled" : this.d.j() != this.b.f() ? "This waterfall is not targeted for the current device" : "Tap to load an ad"; } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ void a(dc dcVar, z zVar, a0 a0Var, com.applovin.impl.sdk.j jVar, MaxDebuggerAdUnitDetailActivity maxDebuggerAdUnitDetailActivity) { maxDebuggerAdUnitDetailActivity.initialize(zVar, a0Var, ((y.b) dcVar).v(), jVar); } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(final com.applovin.impl.sdk.j jVar, final z zVar, final a0 a0Var, lb lbVar, final dc dcVar) { if (dcVar instanceof y.b) { r.a(this, MaxDebuggerAdUnitDetailActivity.class, jVar.e(), new r.b() { // from class: com.applovin.impl.x$$ExternalSyntheticLambda1 @Override // com.applovin.impl.r.b public final void a(Activity activity) { x.a(dc.this, zVar, a0Var, jVar, (MaxDebuggerAdUnitDetailActivity) activity); } }); } } @Override // com.applovin.mediation.MaxAdListener public void onAdLoadFailed(@NonNull String str, @NonNull MaxError maxError) { this.r.setControlState(AdControlButton.b.LOAD); this.s.setText(""); if (204 == maxError.getCode()) { yp.a("No Fill", "No fills often happen in live environments. Please make sure to use the Mediation Debugger test mode before you go live.", this); return; } yp.a("", "Failed to load with error code: " + maxError.getCode(), this); } private void a(MaxAdFormat maxAdFormat) { if (this.c != null) { this.a.l0().a(this.c.b().b()); } if (maxAdFormat.isAdViewAd()) { this.f.setPlacement("[Mediation Debugger Live Ad]"); this.f.loadAd(); return; } if (MaxAdFormat.INTERSTITIAL == this.b.a()) { this.g.loadAd(); return; } if (MaxAdFormat.APP_OPEN == this.b.a()) { this.h.loadAd(); return; } if (MaxAdFormat.REWARDED_INTERSTITIAL == this.b.a()) { this.i.loadAd(); return; } if (MaxAdFormat.REWARDED == this.b.a()) { this.j.loadAd(); } else if (MaxAdFormat.NATIVE == this.b.a()) { this.l.setPlacement("[Mediation Debugger Live Ad]"); this.l.loadAd(); } else { yp.a("Live ads currently unavailable for ad format", this); } } private void a(ViewGroup viewGroup, AppLovinSdkUtils.Size size) { if (this.n != null) { return; } d0 d0Var = new d0(viewGroup, size, this); this.n = d0Var; d0Var.setOnDismissListener(new DialogInterface.OnDismissListener() { // from class: com.applovin.impl.x$$ExternalSyntheticLambda0 @Override // android.content.DialogInterface.OnDismissListener public final void onDismiss(DialogInterface dialogInterface) { x.this.a(dialogInterface); } }); this.n.show(); } }