- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
949 lines
48 KiB
Java
949 lines
48 KiB
Java
package com.applovin.mediation.adapters;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.applovin.impl.sdk.utils.BundleUtils;
|
|
import com.applovin.mediation.MaxAdFormat;
|
|
import com.applovin.mediation.MaxReward;
|
|
import com.applovin.mediation.adapter.MaxAdViewAdapter;
|
|
import com.applovin.mediation.adapter.MaxAdapter;
|
|
import com.applovin.mediation.adapter.MaxAdapterError;
|
|
import com.applovin.mediation.adapter.MaxInterstitialAdapter;
|
|
import com.applovin.mediation.adapter.MaxRewardedAdapter;
|
|
import com.applovin.mediation.adapter.MaxSignalProvider;
|
|
import com.applovin.mediation.adapter.listeners.MaxAdViewAdapterListener;
|
|
import com.applovin.mediation.adapter.listeners.MaxAppOpenAdapterListener;
|
|
import com.applovin.mediation.adapter.listeners.MaxInterstitialAdapterListener;
|
|
import com.applovin.mediation.adapter.listeners.MaxNativeAdAdapterListener;
|
|
import com.applovin.mediation.adapter.listeners.MaxRewardedAdapterListener;
|
|
import com.applovin.mediation.adapter.listeners.MaxSignalCollectionListener;
|
|
import com.applovin.mediation.adapter.parameters.MaxAdapterInitializationParameters;
|
|
import com.applovin.mediation.adapter.parameters.MaxAdapterParameters;
|
|
import com.applovin.mediation.adapter.parameters.MaxAdapterResponseParameters;
|
|
import com.applovin.mediation.adapter.parameters.MaxAdapterSignalCollectionParameters;
|
|
import com.applovin.mediation.nativeAds.MaxNativeAd;
|
|
import com.applovin.mediation.nativeAds.MaxNativeAdView;
|
|
import com.applovin.sdk.AppLovinSdk;
|
|
import com.applovin.sdk.AppLovinSdkUtils;
|
|
import com.mbridge.msdk.foundation.entity.CampaignEx;
|
|
import com.vungle.ads.AdConfig;
|
|
import com.vungle.ads.BannerAd;
|
|
import com.vungle.ads.BannerAdListener;
|
|
import com.vungle.ads.BannerAdSize;
|
|
import com.vungle.ads.BannerView;
|
|
import com.vungle.ads.BaseAd;
|
|
import com.vungle.ads.BuildConfig;
|
|
import com.vungle.ads.InitializationListener;
|
|
import com.vungle.ads.InterstitialAd;
|
|
import com.vungle.ads.InterstitialAdListener;
|
|
import com.vungle.ads.NativeAd;
|
|
import com.vungle.ads.NativeAdListener;
|
|
import com.vungle.ads.RewardedAd;
|
|
import com.vungle.ads.RewardedAdListener;
|
|
import com.vungle.ads.VungleAds;
|
|
import com.vungle.ads.VungleError;
|
|
import com.vungle.ads.VunglePrivacySettings;
|
|
import com.vungle.ads.internal.ui.view.MediaView;
|
|
import csdk.gluads.max.EAMax;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class VungleMediationAdapter extends MediationAdapterBase implements MaxSignalProvider, MaxInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter {
|
|
private static MaxAdapter.InitializationStatus initializationStatus;
|
|
private static final AtomicBoolean initialized = new AtomicBoolean();
|
|
private InterstitialAd appOpenAd;
|
|
private BannerAd bannerAd;
|
|
private InterstitialAd interstitialAd;
|
|
private NativeAd nativeAd;
|
|
private RewardedAd rewardedAd;
|
|
|
|
public VungleMediationAdapter(AppLovinSdk appLovinSdk) {
|
|
super(appLovinSdk);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxAdapter
|
|
public void initialize(MaxAdapterInitializationParameters maxAdapterInitializationParameters, Activity activity, final MaxAdapter.OnCompletionListener onCompletionListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), onCompletionListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
updateUserPrivacySettings(maxAdapterInitializationParameters);
|
|
if (initialized.compareAndSet(false, true)) {
|
|
String string = maxAdapterInitializationParameters.getServerParameters().getString("app_id", null);
|
|
log("Initializing Vungle SDK with app id: " + string + "...");
|
|
initializationStatus = MaxAdapter.InitializationStatus.INITIALIZING;
|
|
VungleAds.setIntegrationName(VungleAds.WrapperFramework.max, getAdapterVersion());
|
|
VungleAds.init(getContext(activity), string, new InitializationListener() { // from class: com.applovin.mediation.adapters.VungleMediationAdapter.1
|
|
@Override // com.vungle.ads.InitializationListener
|
|
public void onSuccess() {
|
|
VungleMediationAdapter.this.log("Vungle SDK initialized");
|
|
MaxAdapter.InitializationStatus unused = VungleMediationAdapter.initializationStatus = MaxAdapter.InitializationStatus.INITIALIZED_SUCCESS;
|
|
onCompletionListener.onCompletion(VungleMediationAdapter.initializationStatus, null);
|
|
}
|
|
|
|
@Override // com.vungle.ads.InitializationListener
|
|
public void onError(@NonNull VungleError vungleError) {
|
|
VungleMediationAdapter.initialized.set(false);
|
|
VungleMediationAdapter.this.log("Vungle SDK failed to initialize with error: ", vungleError);
|
|
MaxAdapter.InitializationStatus unused = VungleMediationAdapter.initializationStatus = MaxAdapter.InitializationStatus.INITIALIZED_FAILURE;
|
|
onCompletionListener.onCompletion(VungleMediationAdapter.initializationStatus, vungleError.getErrorMessage());
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
log("Vungle SDK already initialized");
|
|
onCompletionListener.onCompletion(initializationStatus, null);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxAdapter
|
|
public String getSdkVersion() {
|
|
return getVersionString(BuildConfig.class, "VERSION_NAME");
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxAdapter
|
|
public String getAdapterVersion() {
|
|
return com.applovin.mediation.adapters.vungle.BuildConfig.VERSION_NAME;
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxAdapter
|
|
public void onDestroy() {
|
|
BannerAd bannerAd = this.bannerAd;
|
|
if (bannerAd != null) {
|
|
bannerAd.setAdListener(null);
|
|
this.bannerAd.finishAd();
|
|
this.bannerAd = null;
|
|
}
|
|
NativeAd nativeAd = this.nativeAd;
|
|
if (nativeAd != null) {
|
|
nativeAd.setAdListener(null);
|
|
this.nativeAd.unregisterView();
|
|
this.nativeAd = null;
|
|
}
|
|
InterstitialAd interstitialAd = this.interstitialAd;
|
|
if (interstitialAd != null) {
|
|
interstitialAd.setAdListener(null);
|
|
this.interstitialAd = null;
|
|
}
|
|
RewardedAd rewardedAd = this.rewardedAd;
|
|
if (rewardedAd != null) {
|
|
rewardedAd.setAdListener(null);
|
|
this.rewardedAd = null;
|
|
}
|
|
InterstitialAd interstitialAd2 = this.appOpenAd;
|
|
if (interstitialAd2 != null) {
|
|
interstitialAd2.setAdListener(null);
|
|
this.appOpenAd = null;
|
|
}
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxSignalProvider
|
|
public void collectSignal(MaxAdapterSignalCollectionParameters maxAdapterSignalCollectionParameters, Activity activity, MaxSignalCollectionListener maxSignalCollectionListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxSignalCollectionListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
log("Collecting signal...");
|
|
updateUserPrivacySettings(maxAdapterSignalCollectionParameters);
|
|
maxSignalCollectionListener.onSignalCollected(VungleAds.getBiddingToken(getContext(activity)));
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxInterstitialAdapter
|
|
public void loadInterstitialAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxInterstitialAdapterListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
String bidResponse = maxAdapterResponseParameters.getBidResponse();
|
|
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
|
|
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Loading ");
|
|
sb.append(isValidString ? "bidding " : "");
|
|
sb.append("interstitial ad for placement: ");
|
|
sb.append(thirdPartyAdPlacementId);
|
|
sb.append("...");
|
|
log(sb.toString());
|
|
if (shouldFailAdLoadWhenSdkNotInitialized(maxAdapterResponseParameters) && !VungleAds.isInitialized()) {
|
|
log("Vungle SDK not successfully initialized: failing interstitial ad load...");
|
|
maxInterstitialAdapterListener.onInterstitialAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
|
|
return;
|
|
}
|
|
updateUserPrivacySettings(maxAdapterResponseParameters);
|
|
InterstitialAd interstitialAd = new InterstitialAd(getContext(activity), thirdPartyAdPlacementId, new AdConfig());
|
|
this.interstitialAd = interstitialAd;
|
|
interstitialAd.setAdListener(new InterstitialListener(maxInterstitialAdapterListener));
|
|
this.interstitialAd.load(bidResponse);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxInterstitialAdapter
|
|
public void showInterstitialAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxInterstitialAdapterListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
InterstitialAd interstitialAd = this.interstitialAd;
|
|
if (interstitialAd != null && interstitialAd.canPlayAd().booleanValue()) {
|
|
log("Showing interstitial ad for placement: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
this.interstitialAd.play(getContext(activity));
|
|
return;
|
|
}
|
|
log("Interstitial ad is not ready: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
maxInterstitialAdapterListener.onInterstitialAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "Interstitial ad is not ready"));
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapters.MediationAdapterBase, com.applovin.mediation.adapter.MaxAppOpenAdapter
|
|
public void loadAppOpenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, @Nullable Activity activity, MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
|
|
String bidResponse = maxAdapterResponseParameters.getBidResponse();
|
|
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
|
|
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Loading ");
|
|
sb.append(isValidString ? "bidding " : "");
|
|
sb.append("app open ad for placement: ");
|
|
sb.append(thirdPartyAdPlacementId);
|
|
sb.append("...");
|
|
log(sb.toString());
|
|
if (shouldFailAdLoadWhenSdkNotInitialized(maxAdapterResponseParameters) && !VungleAds.isInitialized()) {
|
|
log("Vungle SDK not successfully initialized: failing app open ad load...");
|
|
maxAppOpenAdapterListener.onAppOpenAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
|
|
return;
|
|
}
|
|
updateUserPrivacySettings(maxAdapterResponseParameters);
|
|
InterstitialAd interstitialAd = new InterstitialAd(getContext(activity), thirdPartyAdPlacementId, new AdConfig());
|
|
this.appOpenAd = interstitialAd;
|
|
interstitialAd.setAdListener(new AppOpenAdListener(maxAppOpenAdapterListener));
|
|
this.appOpenAd.load(bidResponse);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapters.MediationAdapterBase, com.applovin.mediation.adapter.MaxAppOpenAdapter
|
|
public void showAppOpenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, @Nullable Activity activity, MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
|
|
InterstitialAd interstitialAd = this.appOpenAd;
|
|
if (interstitialAd != null && interstitialAd.canPlayAd().booleanValue()) {
|
|
log("Showing app open ad for placement: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
this.appOpenAd.play(getContext(activity));
|
|
return;
|
|
}
|
|
log("App open ad is not ready: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
maxAppOpenAdapterListener.onAppOpenAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "App open ad is not ready"));
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxRewardedAdapter
|
|
public void loadRewardedAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxRewardedAdapterListener maxRewardedAdapterListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxRewardedAdapterListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
String bidResponse = maxAdapterResponseParameters.getBidResponse();
|
|
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
|
|
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Loading ");
|
|
sb.append(isValidString ? "bidding " : "");
|
|
sb.append("rewarded ad for placement: ");
|
|
sb.append(thirdPartyAdPlacementId);
|
|
sb.append("...");
|
|
log(sb.toString());
|
|
if (shouldFailAdLoadWhenSdkNotInitialized(maxAdapterResponseParameters) && !VungleAds.isInitialized()) {
|
|
log("Vungle SDK not successfully initialized: failing rewarded ad load...");
|
|
maxRewardedAdapterListener.onRewardedAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
|
|
return;
|
|
}
|
|
updateUserPrivacySettings(maxAdapterResponseParameters);
|
|
RewardedAd rewardedAd = new RewardedAd(getContext(activity), thirdPartyAdPlacementId, new AdConfig());
|
|
this.rewardedAd = rewardedAd;
|
|
rewardedAd.setAdListener(new RewardedListener(maxRewardedAdapterListener));
|
|
this.rewardedAd.load(bidResponse);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxRewardedAdapter
|
|
public void showRewardedAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxRewardedAdapterListener maxRewardedAdapterListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxRewardedAdapterListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
RewardedAd rewardedAd = this.rewardedAd;
|
|
if (rewardedAd != null && rewardedAd.canPlayAd().booleanValue()) {
|
|
log("Showing rewarded ad for placement: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
configureReward(maxAdapterResponseParameters);
|
|
this.rewardedAd.play(getContext(activity));
|
|
return;
|
|
}
|
|
log("Rewarded ad is not ready: " + maxAdapterResponseParameters.getThirdPartyAdPlacementId() + "...");
|
|
maxRewardedAdapterListener.onRewardedAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "Rewarded ad is not ready"));
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapter.MaxAdViewAdapter
|
|
public void loadAdViewAd(MaxAdapterResponseParameters maxAdapterResponseParameters, MaxAdFormat maxAdFormat, Activity activity, MaxAdViewAdapterListener maxAdViewAdapterListener) {
|
|
String bidResponse = maxAdapterResponseParameters.getBidResponse();
|
|
String label = maxAdFormat.getLabel();
|
|
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
|
|
Context context = getContext(activity);
|
|
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
|
|
boolean z = maxAdapterResponseParameters.getServerParameters().getBoolean("is_native");
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Loading ");
|
|
sb.append(isValidString ? "bidding " : "");
|
|
sb.append(z ? "native " : "");
|
|
sb.append(label);
|
|
sb.append(" ad for placement: ");
|
|
sb.append(thirdPartyAdPlacementId);
|
|
sb.append("...");
|
|
log(sb.toString());
|
|
if (shouldFailAdLoadWhenSdkNotInitialized(maxAdapterResponseParameters) && !VungleAds.isInitialized()) {
|
|
log("Vungle SDK not successfully initialized: failing " + label + " ad load...");
|
|
maxAdViewAdapterListener.onAdViewAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
|
|
return;
|
|
}
|
|
updateUserPrivacySettings(maxAdapterResponseParameters);
|
|
if (z) {
|
|
NativeAdViewListener nativeAdViewListener = new NativeAdViewListener(maxAdapterResponseParameters, maxAdFormat, context, maxAdViewAdapterListener);
|
|
NativeAd nativeAd = new NativeAd(activity, thirdPartyAdPlacementId);
|
|
this.nativeAd = nativeAd;
|
|
nativeAd.setAdListener(nativeAdViewListener);
|
|
this.nativeAd.load(bidResponse);
|
|
return;
|
|
}
|
|
BannerAd bannerAd = new BannerAd(context, thirdPartyAdPlacementId, vungleAdSize(maxAdFormat));
|
|
this.bannerAd = bannerAd;
|
|
bannerAd.setAdListener(new AdViewAdListener(label, maxAdViewAdapterListener));
|
|
this.bannerAd.load(bidResponse);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.adapters.MediationAdapterBase, com.applovin.mediation.adapter.MaxNativeAdAdapter
|
|
public void loadNativeAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxNativeAdAdapterListener maxNativeAdAdapterListener) {
|
|
String bidResponse = maxAdapterResponseParameters.getBidResponse();
|
|
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
|
|
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Loading ");
|
|
sb.append(isValidString ? "bidding " : "");
|
|
sb.append("native ad for placement: ");
|
|
sb.append(thirdPartyAdPlacementId);
|
|
sb.append("...");
|
|
log(sb.toString());
|
|
if (shouldFailAdLoadWhenSdkNotInitialized(maxAdapterResponseParameters) && !VungleAds.isInitialized()) {
|
|
log("Vungle SDK not successfully initialized: failing interstitial ad load...");
|
|
maxNativeAdAdapterListener.onNativeAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
|
|
return;
|
|
}
|
|
updateUserPrivacySettings(maxAdapterResponseParameters);
|
|
NativeAd nativeAd = new NativeAd(activity, thirdPartyAdPlacementId);
|
|
this.nativeAd = nativeAd;
|
|
nativeAd.setAdListener(new NativeListener(maxAdapterResponseParameters, getContext(activity), maxNativeAdAdapterListener));
|
|
this.nativeAd.load(bidResponse);
|
|
}
|
|
|
|
private boolean shouldFailAdLoadWhenSdkNotInitialized(MaxAdapterResponseParameters maxAdapterResponseParameters) {
|
|
return maxAdapterResponseParameters.getServerParameters().getBoolean("fail_ad_load_when_sdk_not_initialized", true);
|
|
}
|
|
|
|
private void updateUserPrivacySettings(MaxAdapterParameters maxAdapterParameters) {
|
|
Boolean hasUserConsent = maxAdapterParameters.hasUserConsent();
|
|
if (hasUserConsent != null) {
|
|
VunglePrivacySettings.setGDPRStatus(hasUserConsent.booleanValue(), "");
|
|
}
|
|
if (maxAdapterParameters.isDoNotSell() != null) {
|
|
VunglePrivacySettings.setCCPAStatus(!r3.booleanValue());
|
|
}
|
|
}
|
|
|
|
private static BannerAdSize vungleAdSize(MaxAdFormat maxAdFormat) {
|
|
if (maxAdFormat == MaxAdFormat.BANNER) {
|
|
return BannerAdSize.BANNER;
|
|
}
|
|
if (maxAdFormat == MaxAdFormat.LEADER) {
|
|
return BannerAdSize.BANNER_LEADERBOARD;
|
|
}
|
|
if (maxAdFormat == MaxAdFormat.MREC) {
|
|
return BannerAdSize.VUNGLE_MREC;
|
|
}
|
|
throw new IllegalArgumentException("Unsupported ad view ad format: " + maxAdFormat.getLabel());
|
|
}
|
|
|
|
private Context getContext(@Nullable Activity activity) {
|
|
return activity != null ? activity.getApplicationContext() : getApplicationContext();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public List<View> getClickableViews(MaxNativeAdView maxNativeAdView) {
|
|
ArrayList arrayList = new ArrayList(6);
|
|
if (maxNativeAdView.getTitleTextView() != null) {
|
|
arrayList.add(maxNativeAdView.getTitleTextView());
|
|
}
|
|
if (maxNativeAdView.getAdvertiserTextView() != null) {
|
|
arrayList.add(maxNativeAdView.getAdvertiserTextView());
|
|
}
|
|
if (maxNativeAdView.getBodyTextView() != null) {
|
|
arrayList.add(maxNativeAdView.getBodyTextView());
|
|
}
|
|
if (maxNativeAdView.getCallToActionButton() != null) {
|
|
arrayList.add(maxNativeAdView.getCallToActionButton());
|
|
}
|
|
if (maxNativeAdView.getIconImageView() != null) {
|
|
arrayList.add(maxNativeAdView.getIconImageView());
|
|
}
|
|
if (maxNativeAdView.getMediaContentViewGroup() != null) {
|
|
arrayList.add(maxNativeAdView.getMediaContentViewGroup());
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Removed duplicated region for block: B:22:0x0031 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static com.applovin.mediation.adapter.MaxAdapterError toMaxError(com.vungle.ads.VungleError r4) {
|
|
/*
|
|
int r0 = r4.getCode()
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.UNSPECIFIED
|
|
if (r0 == 0) goto L4b
|
|
r2 = 6
|
|
if (r0 == r2) goto L49
|
|
r2 = 2
|
|
if (r0 == r2) goto L46
|
|
r2 = 3
|
|
if (r0 == r2) goto L49
|
|
r2 = 10010(0x271a, float:1.4027E-41)
|
|
if (r0 == r2) goto L43
|
|
r2 = 10011(0x271b, float:1.4028E-41)
|
|
if (r0 == r2) goto L40
|
|
r2 = 10019(0x2723, float:1.404E-41)
|
|
if (r0 == r2) goto L46
|
|
r2 = 10020(0x2724, float:1.4041E-41)
|
|
if (r0 == r2) goto L40
|
|
switch(r0) {
|
|
case 6: goto L49;
|
|
case 113: goto L43;
|
|
case 130: goto L43;
|
|
case 207: goto L46;
|
|
case 304: goto L3d;
|
|
case 3001: goto L43;
|
|
case 10001: goto L3a;
|
|
case 10003: goto L46;
|
|
case 10024: goto L40;
|
|
case 10028: goto L46;
|
|
case 10038: goto L40;
|
|
case 10047: goto L37;
|
|
default: goto L24;
|
|
}
|
|
L24:
|
|
switch(r0) {
|
|
case 10013: goto L46;
|
|
case 10014: goto L34;
|
|
case 10015: goto L31;
|
|
default: goto L27;
|
|
}
|
|
L27:
|
|
switch(r0) {
|
|
case 10031: goto L2e;
|
|
case 10032: goto L2e;
|
|
case 10033: goto L40;
|
|
case 10034: goto L46;
|
|
case 10035: goto L46;
|
|
default: goto L2a;
|
|
}
|
|
L2a:
|
|
switch(r0) {
|
|
case 10040: goto L43;
|
|
case 10041: goto L43;
|
|
case 10042: goto L31;
|
|
default: goto L2d;
|
|
}
|
|
L2d:
|
|
goto L4b
|
|
L2e:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.WEBVIEW_ERROR
|
|
goto L4b
|
|
L31:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.INVALID_LOAD_STATE
|
|
goto L4b
|
|
L34:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.SERVER_ERROR
|
|
goto L4b
|
|
L37:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.TIMEOUT
|
|
goto L4b
|
|
L3a:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.NO_FILL
|
|
goto L4b
|
|
L3d:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.AD_EXPIRED
|
|
goto L4b
|
|
L40:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.NO_CONNECTION
|
|
goto L4b
|
|
L43:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.INTERNAL_ERROR
|
|
goto L4b
|
|
L46:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.INVALID_CONFIGURATION
|
|
goto L4b
|
|
L49:
|
|
com.applovin.mediation.adapter.MaxAdapterError r1 = com.applovin.mediation.adapter.MaxAdapterError.NOT_INITIALIZED
|
|
L4b:
|
|
com.applovin.mediation.adapter.MaxAdapterError r2 = new com.applovin.mediation.adapter.MaxAdapterError
|
|
int r3 = r1.getErrorCode()
|
|
java.lang.String r1 = r1.getErrorMessage()
|
|
java.lang.String r4 = r4.getLocalizedMessage()
|
|
r2.<init>(r3, r1, r0, r4)
|
|
return r2
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.applovin.mediation.adapters.VungleMediationAdapter.toMaxError(com.vungle.ads.VungleError):com.applovin.mediation.adapter.MaxAdapterError");
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
@Nullable
|
|
public Bundle maybeCreateExtraInfoBundle(BaseAd baseAd) {
|
|
String creativeId = baseAd.getCreativeId();
|
|
if (TextUtils.isEmpty(creativeId)) {
|
|
return null;
|
|
}
|
|
Bundle bundle = new Bundle(1);
|
|
bundle.putString(CampaignEx.JSON_KEY_CREATIVE_ID, creativeId);
|
|
return bundle;
|
|
}
|
|
|
|
public class InterstitialListener implements InterstitialAdListener {
|
|
private final MaxInterstitialAdapterListener listener;
|
|
|
|
public InterstitialListener(MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
|
|
if (EAMax.adapterDisabled(getClass().getName(), maxInterstitialAdapterListener)) {
|
|
throw new RuntimeException("Adapter is disabled.");
|
|
}
|
|
this.listener = maxInterstitialAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad loaded");
|
|
this.listener.onInterstitialAdLoaded(VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Interstitial ad failed to load with error: " + maxError);
|
|
this.listener.onInterstitialAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad started");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad displayed");
|
|
this.listener.onInterstitialAdDisplayed();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Interstitial ad failed to display with error: " + maxError);
|
|
this.listener.onInterstitialAdDisplayFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad clicked");
|
|
this.listener.onInterstitialAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad left application");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Interstitial ad hidden");
|
|
this.listener.onInterstitialAdHidden();
|
|
}
|
|
}
|
|
|
|
public class AppOpenAdListener implements InterstitialAdListener {
|
|
private final MaxAppOpenAdapterListener listener;
|
|
|
|
public AppOpenAdListener(MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
|
|
this.listener = maxAppOpenAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad loaded");
|
|
this.listener.onAppOpenAdLoaded(VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("App Open ad failed to load with error: " + maxError);
|
|
this.listener.onAppOpenAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad started");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad displayed");
|
|
this.listener.onAppOpenAdDisplayed();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("App Open ad failed to display with error: " + maxError);
|
|
this.listener.onAppOpenAdDisplayFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad clicked");
|
|
this.listener.onAppOpenAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad left application");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("App Open ad hidden");
|
|
this.listener.onAppOpenAdHidden();
|
|
}
|
|
}
|
|
|
|
public class RewardedListener implements RewardedAdListener {
|
|
private boolean hasGrantedReward;
|
|
private final MaxRewardedAdapterListener listener;
|
|
|
|
public RewardedListener(MaxRewardedAdapterListener maxRewardedAdapterListener) {
|
|
this.listener = maxRewardedAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad loaded");
|
|
this.listener.onRewardedAdLoaded(VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Rewarded ad failed to load with error: " + maxError);
|
|
this.listener.onRewardedAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad started");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad displayed");
|
|
this.listener.onRewardedAdDisplayed();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Rewarded ad failed to display with error: " + maxError);
|
|
this.listener.onRewardedAdDisplayFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad clicked");
|
|
this.listener.onRewardedAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad left application");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Rewarded ad video completed");
|
|
if (this.hasGrantedReward || VungleMediationAdapter.this.shouldAlwaysRewardUser()) {
|
|
MaxReward reward = VungleMediationAdapter.this.getReward();
|
|
VungleMediationAdapter.this.log("Rewarded user with reward: " + reward);
|
|
this.listener.onUserRewarded(reward);
|
|
}
|
|
VungleMediationAdapter.this.log("Rewarded ad hidden");
|
|
this.listener.onRewardedAdHidden();
|
|
}
|
|
|
|
@Override // com.vungle.ads.RewardedAdListener
|
|
public void onAdRewarded(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("User was rewarded");
|
|
this.hasGrantedReward = true;
|
|
}
|
|
}
|
|
|
|
public class AdViewAdListener implements BannerAdListener {
|
|
private final String adFormatLabel;
|
|
private final MaxAdViewAdapterListener listener;
|
|
|
|
public AdViewAdListener(String str, MaxAdViewAdapterListener maxAdViewAdapterListener) {
|
|
this.adFormatLabel = str;
|
|
this.listener = maxAdViewAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Showing " + this.adFormatLabel + " ad for placement: " + baseAd.getPlacementId() + "...");
|
|
if (VungleMediationAdapter.this.bannerAd != null && VungleMediationAdapter.this.bannerAd.getBannerView() != null) {
|
|
BannerView bannerView = VungleMediationAdapter.this.bannerAd.getBannerView();
|
|
bannerView.setGravity(17);
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad loaded");
|
|
this.listener.onAdViewAdLoaded(bannerView, VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
return;
|
|
}
|
|
MaxAdapterError maxAdapterError = MaxAdapterError.INVALID_LOAD_STATE;
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad failed to load: " + maxAdapterError);
|
|
this.listener.onAdViewAdLoadFailed(maxAdapterError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad failed to load with error: " + maxError);
|
|
this.listener.onAdViewAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad started");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad displayed");
|
|
this.listener.onAdViewAdDisplayed();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad display failed with error: " + maxError);
|
|
this.listener.onAdViewAdDisplayFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad clicked");
|
|
this.listener.onAdViewAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad left application");
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log(this.adFormatLabel + " ad hidden");
|
|
this.listener.onAdViewAdHidden();
|
|
}
|
|
}
|
|
|
|
public class NativeAdViewListener implements NativeAdListener {
|
|
private final MaxAdFormat adFormat;
|
|
private final Context applicationContext;
|
|
private final MaxAdViewAdapterListener listener;
|
|
private final Bundle serverParameters;
|
|
|
|
public NativeAdViewListener(MaxAdapterResponseParameters maxAdapterResponseParameters, MaxAdFormat maxAdFormat, Context context, MaxAdViewAdapterListener maxAdViewAdapterListener) {
|
|
this.serverParameters = maxAdapterResponseParameters.getServerParameters();
|
|
this.adFormat = maxAdFormat;
|
|
this.applicationContext = context;
|
|
this.listener = maxAdViewAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
MaxNativeAdView maxNativeAdView;
|
|
if (VungleMediationAdapter.this.nativeAd != null && VungleMediationAdapter.this.nativeAd == baseAd) {
|
|
if (TextUtils.isEmpty(VungleMediationAdapter.this.nativeAd.getAdTitle())) {
|
|
VungleMediationAdapter.this.e("Native " + this.adFormat.getLabel() + " ad (" + VungleMediationAdapter.this.nativeAd + ") does not have required assets.");
|
|
this.listener.onAdViewAdLoadFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_MISSING_REQUIRED_NATIVE_AD_ASSETS, "Missing Native Ad Assets"));
|
|
return;
|
|
}
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad loaded: " + VungleMediationAdapter.this.nativeAd.getPlacementId());
|
|
MaxVungleNativeAd maxVungleNativeAd = VungleMediationAdapter.this.new MaxVungleNativeAd(new MaxNativeAd.Builder().setAdFormat(this.adFormat).setTitle(VungleMediationAdapter.this.nativeAd.getAdTitle()).setAdvertiser(VungleMediationAdapter.this.nativeAd.getAdSponsoredText()).setBody(VungleMediationAdapter.this.nativeAd.getAdBodyText()).setCallToAction(VungleMediationAdapter.this.nativeAd.getAdCallToActionText()).setIcon(new MaxNativeAd.MaxNativeAdImage(Uri.parse(VungleMediationAdapter.this.nativeAd.getAppIcon()))).setMediaView(new MediaView(this.applicationContext)));
|
|
String string = BundleUtils.getString("template", "", this.serverParameters);
|
|
if (string.contains("vertical")) {
|
|
if (string.equals("vertical")) {
|
|
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, this.adFormat == MaxAdFormat.LEADER ? "vertical_leader_template" : "vertical_media_banner_template", this.applicationContext);
|
|
} else {
|
|
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, string, this.applicationContext);
|
|
}
|
|
} else {
|
|
if (!AppLovinSdkUtils.isValidString(string)) {
|
|
string = "media_banner_template";
|
|
}
|
|
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, string, this.applicationContext);
|
|
}
|
|
maxVungleNativeAd.prepareForInteraction(VungleMediationAdapter.this.getClickableViews(maxNativeAdView), maxNativeAdView);
|
|
this.listener.onAdViewAdLoaded(maxNativeAdView, VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
return;
|
|
}
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad failed to load: no fill");
|
|
this.listener.onAdViewAdLoadFailed(MaxAdapterError.NO_FILL);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad failed to load with error " + maxError + " with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onAdViewAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad start with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad shown with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onAdViewAdDisplayed();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad failed to play with error " + VungleMediationAdapter.toMaxError(vungleError) + " with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad clicked with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onAdViewAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad left application with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native " + this.adFormat.getLabel() + " ad end with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
}
|
|
|
|
public class NativeListener implements NativeAdListener {
|
|
private final Context applicationContext;
|
|
private final MaxNativeAdAdapterListener listener;
|
|
private final Bundle serverParameters;
|
|
|
|
public NativeListener(MaxAdapterResponseParameters maxAdapterResponseParameters, Context context, MaxNativeAdAdapterListener maxNativeAdAdapterListener) {
|
|
this.serverParameters = maxAdapterResponseParameters.getServerParameters();
|
|
this.applicationContext = context;
|
|
this.listener = maxNativeAdAdapterListener;
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLoaded(BaseAd baseAd) {
|
|
if (VungleMediationAdapter.this.nativeAd == null || VungleMediationAdapter.this.nativeAd != baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad failed to load: no fill");
|
|
this.listener.onNativeAdLoadFailed(MaxAdapterError.NO_FILL);
|
|
return;
|
|
}
|
|
if (AppLovinSdkUtils.isValidString(BundleUtils.getString("template", "", this.serverParameters)) && TextUtils.isEmpty(VungleMediationAdapter.this.nativeAd.getAdTitle())) {
|
|
VungleMediationAdapter.this.e("Native ad (" + VungleMediationAdapter.this.nativeAd + ") does not have required assets.");
|
|
this.listener.onNativeAdLoadFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_MISSING_REQUIRED_NATIVE_AD_ASSETS, "Missing Native Ad Assets"));
|
|
return;
|
|
}
|
|
VungleMediationAdapter.this.log("Native ad loaded: " + VungleMediationAdapter.this.nativeAd.getPlacementId());
|
|
this.listener.onNativeAdLoaded(VungleMediationAdapter.this.new MaxVungleNativeAd(new MaxNativeAd.Builder().setAdFormat(MaxAdFormat.NATIVE).setTitle(VungleMediationAdapter.this.nativeAd.getAdTitle()).setAdvertiser(VungleMediationAdapter.this.nativeAd.getAdSponsoredText()).setBody(VungleMediationAdapter.this.nativeAd.getAdBodyText()).setCallToAction(VungleMediationAdapter.this.nativeAd.getAdCallToActionText()).setIcon(new MaxNativeAd.MaxNativeAdImage(Uri.parse(VungleMediationAdapter.this.nativeAd.getAppIcon()))).setMediaView(new MediaView(this.applicationContext))), VungleMediationAdapter.this.maybeCreateExtraInfoBundle(baseAd));
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToLoad(BaseAd baseAd, VungleError vungleError) {
|
|
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleError);
|
|
VungleMediationAdapter.this.log("Native ad failed to load with error " + maxError + " with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onNativeAdLoadFailed(maxError);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdStart(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad start with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdImpression(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad shown with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onNativeAdDisplayed(null);
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdFailedToPlay(BaseAd baseAd, VungleError vungleError) {
|
|
VungleMediationAdapter.this.log("Native ad failed to play with error " + VungleMediationAdapter.toMaxError(vungleError) + " with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdClicked(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad clicked with placement id: " + baseAd.getPlacementId());
|
|
this.listener.onNativeAdClicked();
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdLeftApplication(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad left application with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
|
|
@Override // com.vungle.ads.BaseAdListener
|
|
public void onAdEnd(BaseAd baseAd) {
|
|
VungleMediationAdapter.this.log("Native ad end with placement id: " + baseAd.getPlacementId());
|
|
}
|
|
}
|
|
|
|
public class MaxVungleNativeAd extends MaxNativeAd {
|
|
public MaxVungleNativeAd(MaxNativeAd.Builder builder) {
|
|
super(builder);
|
|
}
|
|
|
|
@Override // com.applovin.mediation.nativeAds.MaxNativeAd
|
|
public boolean prepareForInteraction(List<View> list, ViewGroup viewGroup) {
|
|
NativeAd nativeAd = VungleMediationAdapter.this.nativeAd;
|
|
if (nativeAd == null) {
|
|
VungleMediationAdapter.this.e("Failed to register native ad views: native ad is null.");
|
|
return false;
|
|
}
|
|
if (!nativeAd.canPlayAd().booleanValue()) {
|
|
VungleMediationAdapter.this.e("Failed to play native ad or native ad is registered.");
|
|
return false;
|
|
}
|
|
View mediaView = getMediaView();
|
|
if (mediaView == null) {
|
|
VungleMediationAdapter.this.e("Failed to register native ad views: mediaView is null.");
|
|
return false;
|
|
}
|
|
if (mediaView.getParent() != null) {
|
|
((ViewGroup) mediaView.getParent()).removeView(mediaView);
|
|
}
|
|
MaxNativeAdView maxNativeAdView = (MaxNativeAdView) viewGroup;
|
|
ViewGroup mediaContentViewGroup = maxNativeAdView.getMediaContentViewGroup();
|
|
if (mediaContentViewGroup != null) {
|
|
mediaContentViewGroup.removeAllViews();
|
|
mediaContentViewGroup.addView(mediaView);
|
|
}
|
|
nativeAd.registerViewForInteraction(maxNativeAdView, (MediaView) mediaView, maxNativeAdView.getIconImageView(), list);
|
|
return true;
|
|
}
|
|
}
|
|
}
|