Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22
以下内容为反编译后的 VungleMediationAdapter.java 源代码,内容仅作参考
package com.applovin.mediation.adapters;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import com.amazon.aps.shared.util.APSSharedUtil;
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.safedk.android.analytics.brandsafety.creatives.discoveries.l;
import com.vungle.warren.AdConfig;
import com.vungle.warren.BannerAdConfig;
import com.vungle.warren.Banners;
import com.vungle.warren.InitCallback;
import com.vungle.warren.LoadAdCallback;
import com.vungle.warren.NativeAd;
import com.vungle.warren.NativeAdLayout;
import com.vungle.warren.PlayAdCallback;
import com.vungle.warren.Plugin;
import com.vungle.warren.Vungle;
import com.vungle.warren.VungleApiClient;
import com.vungle.warren.VungleBanner;
import com.vungle.warren.VungleSettings;
import com.vungle.warren.error.VungleException;
import com.vungle.warren.ui.view.MediaView;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
public class VungleMediationAdapter extends MediationAdapterBase implements MaxSignalProvider, MaxInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter {
private static final AtomicBoolean initialized = new AtomicBoolean();
private static MaxAdapter.InitializationStatus status;
private VungleBanner adViewAd;
private NativeAd nativeAd;
private class AdViewAdListener implements PlayAdCallback {
private final String adFormatLabel;
private String creativeId;
private final MaxAdViewAdapterListener listener;
AdViewAdListener(String str, MaxAdViewAdapterListener maxAdViewAdapterListener) {
this.adFormatLabel = str;
this.listener = maxAdViewAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + "ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad clicked");
this.listener.onAdViewAdClicked();
}
@Override
public void onAdEnd(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad hidden");
this.listener.onAdViewAdHidden();
}
@Override
public void onAdEnd(String str, boolean z, boolean z2) {
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad left application");
}
@Override
public void onAdRewarded(String str) {
}
@Override
public void onAdStart(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad started");
}
@Override
public void onAdViewed(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad displayed");
if (AppLovinSdk.VERSION_CODE < 9150000 || !AppLovinSdkUtils.isValidString(this.creativeId)) {
this.listener.onAdViewAdDisplayed();
return;
}
Bundle bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
this.listener.onAdViewAdDisplayed(bundle);
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(this.adFormatLabel + " ad display failed with error: " + maxError);
this.listener.onAdViewAdDisplayFailed(maxError);
}
}
private class AppOpenAdListener implements PlayAdCallback {
private String creativeId;
private final MaxAppOpenAdapterListener listener;
AppOpenAdListener(MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
this.listener = maxAppOpenAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("App open ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter.this.log("App open ad clicked");
this.listener.onAppOpenAdClicked();
}
@Override
public void onAdEnd(String str) {
VungleMediationAdapter.this.log("App open ad hidden");
this.listener.onAppOpenAdHidden();
}
@Override
public void onAdEnd(String str, boolean z, boolean z2) {
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter.this.log("App open ad left application");
}
@Override
public void onAdRewarded(String str) {
}
@Override
public void onAdStart(String str) {
VungleMediationAdapter.this.log("App open ad started");
}
@Override
public void onAdViewed(String str) {
VungleMediationAdapter.this.log("App open ad displayed");
if (AppLovinSdk.VERSION_CODE < 9150000 || !AppLovinSdkUtils.isValidString(this.creativeId)) {
this.listener.onAppOpenAdDisplayed();
return;
}
Bundle bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
this.listener.onAppOpenAdDisplayed(bundle);
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("App open ad failed to display with error: " + maxError);
this.listener.onAppOpenAdDisplayFailed(maxError);
}
}
private class InterstitialAdListener implements PlayAdCallback {
private String creativeId;
private final MaxInterstitialAdapterListener listener;
InterstitialAdListener(MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
this.listener = maxInterstitialAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Interstitial ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter.this.log("Interstitial ad clicked");
this.listener.onInterstitialAdClicked();
}
@Override
public void onAdEnd(String str) {
VungleMediationAdapter.this.log("Interstitial ad hidden");
this.listener.onInterstitialAdHidden();
}
@Override
public void onAdEnd(String str, boolean z, boolean z2) {
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter.this.log("Interstitial ad left application");
}
@Override
public void onAdRewarded(String str) {
}
@Override
public void onAdStart(String str) {
VungleMediationAdapter.this.log("Interstitial ad started");
}
@Override
public void onAdViewed(String str) {
VungleMediationAdapter.this.log("Interstitial ad displayed");
if (AppLovinSdk.VERSION_CODE < 9150000 || !AppLovinSdkUtils.isValidString(this.creativeId)) {
this.listener.onInterstitialAdDisplayed();
return;
}
Bundle bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
this.listener.onInterstitialAdDisplayed(bundle);
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Interstitial ad failed to display with error: " + maxError);
this.listener.onInterstitialAdDisplayFailed(maxError);
}
}
private class MaxVungleNativeAd extends MaxNativeAd {
public MaxVungleNativeAd(MaxNativeAd.Builder builder) {
super(builder);
}
@Override
public void prepareViewForInteraction(MaxNativeAdView maxNativeAdView) {
NativeAd nativeAd = VungleMediationAdapter.this.nativeAd;
if (nativeAd == null) {
VungleMediationAdapter.this.e("Failed to register native ad views: native ad is null.");
return;
}
NativeAdLayout nativeAdLayout = new NativeAdLayout(maxNativeAdView.getContext());
View mainView = maxNativeAdView.getMainView();
maxNativeAdView.removeView(mainView);
nativeAdLayout.addView(mainView);
maxNativeAdView.addView(nativeAdLayout);
nativeAd.registerViewForInteraction(nativeAdLayout, (MediaView) getMediaView(), maxNativeAdView.getIconImageView(), VungleMediationAdapter.this.getClickableViews(maxNativeAdView));
}
}
private class NativeAdListener implements com.vungle.warren.NativeAdListener {
private final Context applicationContext;
private String creativeId;
private final MaxNativeAdAdapterListener listener;
private final Bundle serverParameters;
NativeAdListener(MaxAdapterResponseParameters maxAdapterResponseParameters, Context context, MaxNativeAdAdapterListener maxNativeAdAdapterListener) {
this.serverParameters = maxAdapterResponseParameters.getServerParameters();
this.applicationContext = context;
this.listener = maxNativeAdAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad clicked with placement id: " + str);
this.listener.onNativeAdClicked();
}
@Override
public void onAdImpression(String str) {
Bundle bundle;
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad shown with placement id: " + str);
if (AppLovinSdkUtils.isValidString(this.creativeId)) {
bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
} else {
bundle = null;
}
this.listener.onNativeAdDisplayed(bundle);
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad left application with placement id: " + str);
}
@Override
public void onAdLoadError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad failed to load with error " + maxError + " with placement id: " + str);
this.listener.onNativeAdLoadFailed(maxError);
}
@Override
public void onAdPlayError(String str, VungleException vungleException) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad failed to play with error " + VungleMediationAdapter.toMaxError(vungleException) + " with placement id: " + str);
}
@Override
public void onNativeAdLoaded(NativeAd nativeAd) {
if (VungleMediationAdapter.this.nativeAd == null || VungleMediationAdapter.this.nativeAd != nativeAd) {
VungleMediationAdapter.this.log("Native ad failed to load: no fill");
this.listener.onNativeAdLoadFailed(MaxAdapterError.NO_FILL);
} else if (!AppLovinSdkUtils.isValidString(BundleUtils.getString("template", "", this.serverParameters)) || !TextUtils.isEmpty(VungleMediationAdapter.this.nativeAd.getAdTitle())) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native ad loaded: " + VungleMediationAdapter.this.nativeAd.getPlacementId());
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
NativeAdListener.this.listener.onNativeAdLoaded(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(NativeAdListener.this.applicationContext))), null);
}
});
} else {
VungleMediationAdapter vungleMediationAdapter2 = VungleMediationAdapter.this;
vungleMediationAdapter2.e("Native ad (" + VungleMediationAdapter.this.nativeAd + ") does not have required assets.");
this.listener.onNativeAdLoadFailed(new MaxAdapterError((int) MaxAdapterError.ERROR_CODE_MISSING_REQUIRED_NATIVE_AD_ASSETS, "Missing Native Ad Assets"));
}
}
}
private class NativeAdViewListener implements com.vungle.warren.NativeAdListener {
private final MaxAdFormat adFormat;
private final Context applicationContext;
private String creativeId;
private final MaxAdViewAdapterListener listener;
private final Bundle serverParameters;
NativeAdViewListener(MaxAdapterResponseParameters maxAdapterResponseParameters, MaxAdFormat maxAdFormat, Context context, MaxAdViewAdapterListener maxAdViewAdapterListener) {
this.serverParameters = maxAdapterResponseParameters.getServerParameters();
this.adFormat = maxAdFormat;
this.applicationContext = context;
this.listener = maxAdViewAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad clicked with placement id: " + str);
this.listener.onAdViewAdClicked();
}
@Override
public void onAdImpression(String str) {
Bundle bundle;
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad shown with placement id: " + str);
if (AppLovinSdkUtils.isValidString(this.creativeId)) {
bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
} else {
bundle = null;
}
this.listener.onAdViewAdDisplayed(bundle);
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad left application with placement id: " + str);
}
@Override
public void onAdLoadError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad failed to load with error " + maxError + " with placement id: " + str);
this.listener.onAdViewAdLoadFailed(maxError);
}
@Override
public void onAdPlayError(String str, VungleException vungleException) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad failed to play with error " + VungleMediationAdapter.toMaxError(vungleException) + " with placement id: " + str);
}
@Override
public void onNativeAdLoaded(NativeAd nativeAd) {
if (VungleMediationAdapter.this.nativeAd == null || VungleMediationAdapter.this.nativeAd != nativeAd) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Native " + this.adFormat.getLabel() + " ad failed to load: no fill");
this.listener.onAdViewAdLoadFailed(MaxAdapterError.NO_FILL);
} else if (!TextUtils.isEmpty(VungleMediationAdapter.this.nativeAd.getAdTitle())) {
VungleMediationAdapter vungleMediationAdapter2 = VungleMediationAdapter.this;
vungleMediationAdapter2.log("Native " + this.adFormat.getLabel() + " ad loaded: " + VungleMediationAdapter.this.nativeAd.getPlacementId());
AppLovinSdkUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
MaxNativeAdView maxNativeAdView;
MaxVungleNativeAd maxVungleNativeAd = new MaxVungleNativeAd(new MaxNativeAd.Builder().setAdFormat(NativeAdViewListener.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(NativeAdViewListener.this.applicationContext)));
String string = BundleUtils.getString("template", "", NativeAdViewListener.this.serverParameters);
if (string.contains("vertical")) {
if (AppLovinSdk.VERSION_CODE < 9140500) {
VungleMediationAdapter.this.log("Vertical native banners are only supported on MAX SDK 9.14.5 and above. Default horizontal native template will be used.");
}
if (string.equals("vertical")) {
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, NativeAdViewListener.this.adFormat == MaxAdFormat.LEADER ? "vertical_leader_template" : "vertical_media_banner_template", NativeAdViewListener.this.applicationContext);
} else {
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, string, NativeAdViewListener.this.applicationContext);
}
} else if (AppLovinSdk.VERSION_CODE < 9140500) {
if (!AppLovinSdkUtils.isValidString(string)) {
string = "no_body_banner_template";
}
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, string, NativeAdViewListener.this.applicationContext);
} else {
if (!AppLovinSdkUtils.isValidString(string)) {
string = "media_banner_template";
}
maxNativeAdView = new MaxNativeAdView(maxVungleNativeAd, string, NativeAdViewListener.this.applicationContext);
}
maxVungleNativeAd.prepareViewForInteraction(maxNativeAdView);
NativeAdViewListener.this.listener.onAdViewAdLoaded(maxNativeAdView);
}
});
} else {
VungleMediationAdapter vungleMediationAdapter3 = VungleMediationAdapter.this;
vungleMediationAdapter3.e("Native " + this.adFormat.getLabel() + " ad (" + VungleMediationAdapter.this.nativeAd + ") does not have required assets.");
this.listener.onAdViewAdLoadFailed(new MaxAdapterError((int) MaxAdapterError.ERROR_CODE_MISSING_REQUIRED_NATIVE_AD_ASSETS, "Missing Native Ad Assets"));
}
}
}
private class RewardedAdListener implements PlayAdCallback {
private String creativeId;
private boolean hasGrantedReward;
private final MaxRewardedAdapterListener listener;
RewardedAdListener(MaxRewardedAdapterListener maxRewardedAdapterListener) {
this.listener = maxRewardedAdapterListener;
}
@Override
public void creativeId(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Rewarded ad with creative id: " + str + " will be played");
this.creativeId = str;
}
@Override
public void onAdClick(String str) {
VungleMediationAdapter.this.log("Rewarded ad clicked");
this.listener.onRewardedAdClicked();
}
@Override
public void onAdEnd(String str) {
VungleMediationAdapter.this.log("Rewarded ad video completed");
this.listener.onRewardedAdVideoCompleted();
if (this.hasGrantedReward || VungleMediationAdapter.this.shouldAlwaysRewardUser()) {
MaxReward reward = VungleMediationAdapter.this.getReward();
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Rewarded user with reward: " + reward);
this.listener.onUserRewarded(reward);
}
VungleMediationAdapter.this.log("Rewarded ad hidden");
this.listener.onRewardedAdHidden();
}
@Override
public void onAdEnd(String str, boolean z, boolean z2) {
}
@Override
public void onAdLeftApplication(String str) {
VungleMediationAdapter.this.log("Rewarded ad left application");
}
@Override
public void onAdRewarded(String str) {
VungleMediationAdapter.this.log("Rewarded ad user did earn reward");
this.hasGrantedReward = true;
}
@Override
public void onAdStart(String str) {
VungleMediationAdapter.this.log("Rewarded ad started");
}
@Override
public void onAdViewed(String str) {
VungleMediationAdapter.this.log("Rewarded ad displayed");
if (AppLovinSdk.VERSION_CODE < 9150000 || !AppLovinSdkUtils.isValidString(this.creativeId)) {
this.listener.onRewardedAdDisplayed();
} else {
Bundle bundle = new Bundle(1);
bundle.putString("creative_id", this.creativeId);
this.listener.onRewardedAdDisplayed(bundle);
}
this.listener.onRewardedAdVideoStarted();
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Rewarded ad failed to display with error: " + maxError);
this.listener.onRewardedAdDisplayFailed(maxError);
}
}
public VungleMediationAdapter(AppLovinSdk appLovinSdk) {
super(appLovinSdk);
}
private AdConfig createAdConfig(Bundle bundle, Context context) {
AdConfig adConfig = new AdConfig();
if (bundle.containsKey("ordinal")) {
adConfig.setOrdinal(bundle.getInt("ordinal"));
}
if (bundle.containsKey("immersive_mode")) {
adConfig.setImmersiveMode(bundle.getBoolean("immersive_mode"));
}
if (bundle.containsKey("is_muted")) {
adConfig.setMuted(bundle.getBoolean("is_muted"));
}
adConfig.setAdOrientation(vungleAdOrientation(context));
return adConfig;
}
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.getIconImageView() != null) {
arrayList.add(maxNativeAdView.getIconImageView());
}
if (maxNativeAdView.getCallToActionButton() != null) {
arrayList.add(maxNativeAdView.getCallToActionButton());
}
ViewGroup mediaContentViewGroup = AppLovinSdk.VERSION_CODE >= 11000000 ? maxNativeAdView.getMediaContentViewGroup() : maxNativeAdView.getMediaContentView();
if (mediaContentViewGroup != null) {
arrayList.add(mediaContentViewGroup);
}
return arrayList;
}
private Context getContext(Activity activity) {
return activity != null ? activity.getApplicationContext() : getApplicationContext();
}
private int getOrientation(Context context) {
Resources resources;
Configuration configuration;
if (context == null || (resources = context.getResources()) == null || (configuration = resources.getConfiguration()) == null) {
return 0;
}
return configuration.orientation;
}
private Boolean getPrivacySetting(String str, MaxAdapterParameters maxAdapterParameters) {
try {
return (Boolean) maxAdapterParameters.getClass().getMethod(str, new Class[0]).invoke(maxAdapterParameters, new Object[0]);
} catch (Exception e) {
log("Error getting privacy setting " + str + " with exception: ", e);
return AppLovinSdk.VERSION_CODE >= 9140000 ? null : false;
}
}
private boolean isValidPlacement(MaxAdapterResponseParameters maxAdapterResponseParameters) {
return Vungle.getValidPlacements().contains(maxAdapterResponseParameters.getThirdPartyAdPlacementId()) || maxAdapterResponseParameters.isTesting();
}
private void loadFullscreenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Context context, LoadAdCallback loadAdCallback) {
AdConfig createAdConfig = createAdConfig(maxAdapterResponseParameters.getServerParameters(), context);
String bidResponse = maxAdapterResponseParameters.getBidResponse();
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
if (AppLovinSdkUtils.isValidString(bidResponse)) {
Vungle.loadAd(thirdPartyAdPlacementId, bidResponse, createAdConfig, loadAdCallback);
} else {
Vungle.loadAd(thirdPartyAdPlacementId, createAdConfig, loadAdCallback);
}
}
private void loadVungleNativeAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Context context, com.vungle.warren.NativeAdListener nativeAdListener) {
AdConfig adConfig = new AdConfig();
String bidResponse = maxAdapterResponseParameters.getBidResponse();
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
updateUserPrivacySettings(maxAdapterResponseParameters);
this.nativeAd = new NativeAd(context, thirdPartyAdPlacementId);
if (AppLovinSdkUtils.isValidString(bidResponse)) {
this.nativeAd.loadAd(adConfig, bidResponse, nativeAdListener);
} else {
this.nativeAd.loadAd(adConfig, nativeAdListener);
}
}
public void showAdViewAd(MaxAdFormat maxAdFormat, BannerAdConfig bannerAdConfig, MaxAdapterResponseParameters maxAdapterResponseParameters, MaxAdViewAdapterListener maxAdViewAdapterListener, PlayAdCallback playAdCallback) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String label = maxAdFormat.getLabel();
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Showing ");
sb.append(isValidString ? "bidding " : "");
sb.append(label);
sb.append(" ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (isValidString) {
this.adViewAd = Banners.getBanner(thirdPartyAdPlacementId, bidResponse, bannerAdConfig, playAdCallback);
} else {
this.adViewAd = Banners.getBanner(thirdPartyAdPlacementId, bannerAdConfig, playAdCallback);
}
if (this.adViewAd != null) {
log(label + " ad loaded");
this.adViewAd.setGravity(17);
maxAdViewAdapterListener.onAdViewAdLoaded(this.adViewAd);
return;
}
MaxAdapterError maxAdapterError = MaxAdapterError.INVALID_LOAD_STATE;
log(label + " ad failed to load: " + maxAdapterError);
maxAdViewAdapterListener.onAdViewAdLoadFailed(maxAdapterError);
}
private void showFullscreenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Context context, PlayAdCallback playAdCallback) {
AdConfig createAdConfig = createAdConfig(maxAdapterResponseParameters.getServerParameters(), context);
String bidResponse = maxAdapterResponseParameters.getBidResponse();
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
if (AppLovinSdkUtils.isValidString(bidResponse)) {
Vungle.playAd(thirdPartyAdPlacementId, bidResponse, createAdConfig, playAdCallback);
} else {
Vungle.playAd(thirdPartyAdPlacementId, createAdConfig, playAdCallback);
}
}
public static MaxAdapterError toMaxError(VungleException vungleException) {
int exceptionCode = vungleException.getExceptionCode();
MaxAdapterError maxAdapterError = MaxAdapterError.UNSPECIFIED;
switch (exceptionCode) {
case 1:
maxAdapterError = MaxAdapterError.NO_FILL;
break;
case 2:
maxAdapterError = MaxAdapterError.UNSPECIFIED;
break;
case 3:
case 5:
case 12:
case 13:
case 17:
case 18:
case 19:
case 28:
case 29:
case 30:
case 34:
case 35:
case 36:
case 41:
maxAdapterError = MaxAdapterError.INVALID_CONFIGURATION;
break;
case 4:
case 37:
maxAdapterError = MaxAdapterError.AD_EXPIRED;
break;
case 6:
case 7:
case 9:
case 16:
maxAdapterError = MaxAdapterError.NOT_INITIALIZED;
break;
case 8:
case 15:
maxAdapterError = MaxAdapterError.INVALID_LOAD_STATE;
break;
case 10:
case 25:
case 39:
case 40:
maxAdapterError = MaxAdapterError.INTERNAL_ERROR;
break;
case 11:
case 20:
case 23:
case 24:
case 33:
case 38:
maxAdapterError = MaxAdapterError.NO_CONNECTION;
break;
case 14:
case 21:
case 22:
case 26:
maxAdapterError = MaxAdapterError.SERVER_ERROR;
break;
case 27:
case 31:
case 32:
maxAdapterError = MaxAdapterError.WEBVIEW_ERROR;
break;
}
return new MaxAdapterError(maxAdapterError.getErrorCode(), maxAdapterError.getErrorMessage(), exceptionCode, vungleException.getLocalizedMessage());
}
private void updateUserPrivacySettings(MaxAdapterParameters maxAdapterParameters) {
Boolean privacySetting;
Boolean privacySetting2 = getPrivacySetting("hasUserConsent", maxAdapterParameters);
if (privacySetting2 != null) {
Vungle.updateConsentStatus(privacySetting2.booleanValue() ? Vungle.Consent.OPTED_IN : Vungle.Consent.OPTED_OUT, "");
}
if (AppLovinSdk.VERSION_CODE < 91100 || (privacySetting = getPrivacySetting("isDoNotSell", maxAdapterParameters)) == null) {
return;
}
Vungle.updateCCPAStatus(privacySetting.booleanValue() ? Vungle.Consent.OPTED_OUT : Vungle.Consent.OPTED_IN);
}
private int vungleAdOrientation(Context context) {
int orientation = getOrientation(context);
if (orientation == 1) {
return 0;
}
return orientation == 2 ? 1 : 2;
}
private static AdConfig.AdSize vungleAdSize(MaxAdFormat maxAdFormat) {
if (maxAdFormat == MaxAdFormat.BANNER) {
return AdConfig.AdSize.BANNER;
}
if (maxAdFormat == MaxAdFormat.LEADER) {
return AdConfig.AdSize.BANNER_LEADERBOARD;
}
if (maxAdFormat == MaxAdFormat.MREC) {
return AdConfig.AdSize.VUNGLE_MREC;
}
throw new IllegalArgumentException("Unsupported ad view ad format: " + maxAdFormat.getLabel());
}
@Override
public void collectSignal(MaxAdapterSignalCollectionParameters maxAdapterSignalCollectionParameters, Activity activity, MaxSignalCollectionListener maxSignalCollectionListener) {
log("Collecting signal...");
updateUserPrivacySettings(maxAdapterSignalCollectionParameters);
maxSignalCollectionListener.onSignalCollected(Vungle.getAvailableBidTokens(activity.getApplicationContext()));
}
@Override
public String getAdapterVersion() {
return "6.12.1.1";
}
@Override
public String getSdkVersion() {
return getVersionString(com.vungle.warren.BuildConfig.class, l.e);
}
@Override
public void initialize(MaxAdapterInitializationParameters maxAdapterInitializationParameters, Activity activity, final MaxAdapter.OnCompletionListener onCompletionListener) {
updateUserPrivacySettings(maxAdapterInitializationParameters);
if (!initialized.compareAndSet(false, true)) {
log("Vungle SDK already initialized");
onCompletionListener.onCompletion(status, null);
return;
}
String string = maxAdapterInitializationParameters.getServerParameters().getString("app_id", null);
log("Initializing Vungle SDK with app id: " + string + APSSharedUtil.TRUNCATE_SEPARATOR);
status = MaxAdapter.InitializationStatus.INITIALIZING;
Boolean privacySetting = getPrivacySetting("isAgeRestrictedUser", maxAdapterInitializationParameters);
if (privacySetting != null) {
Vungle.updateUserCoppaStatus(privacySetting.booleanValue());
}
Plugin.addWrapperInfo(VungleApiClient.WrapperFramework.max, getAdapterVersion());
VungleSettings build = new VungleSettings.Builder().disableBannerRefresh().build();
Vungle.init(string, getContext(activity), new InitCallback() {
@Override
public void onAutoCacheAdAvailable(String str) {
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Auto-cached ad: " + str);
}
@Override
public void onError(VungleException vungleException) {
VungleMediationAdapter.this.log("Vungle SDK failed to initialize with error: ", vungleException);
MaxAdapter.InitializationStatus unused = VungleMediationAdapter.status = MaxAdapter.InitializationStatus.INITIALIZED_FAILURE;
onCompletionListener.onCompletion(VungleMediationAdapter.status, vungleException.getLocalizedMessage());
}
@Override
public void onSuccess() {
VungleMediationAdapter.this.log("Vungle SDK initialized");
MaxAdapter.InitializationStatus unused = VungleMediationAdapter.status = MaxAdapter.InitializationStatus.INITIALIZED_SUCCESS;
onCompletionListener.onCompletion(VungleMediationAdapter.status, null);
}
}, build);
}
@Override
public void loadAdViewAd(final MaxAdapterResponseParameters maxAdapterResponseParameters, final MaxAdFormat maxAdFormat, Activity activity, final MaxAdViewAdapterListener maxAdViewAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
final String label = maxAdFormat.getLabel();
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
boolean z = maxAdapterResponseParameters.getServerParameters().getBoolean("is_native");
StringBuilder sb = new StringBuilder("Loading ");
sb.append(isValidString ? "bidding " : "");
sb.append(z ? "native " : "");
sb.append(label);
sb.append(" ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (!Vungle.isInitialized()) {
log("Vungle SDK not successfully initialized: failing " + label + " ad load...");
maxAdViewAdapterListener.onAdViewAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
} else if (!isValidPlacement(maxAdapterResponseParameters)) {
log(label + " ad failed to load due to an invalid placement id: " + thirdPartyAdPlacementId);
maxAdViewAdapterListener.onAdViewAdLoadFailed(MaxAdapterError.INVALID_CONFIGURATION);
} else if (z) {
Context context = getContext(activity);
loadVungleNativeAd(maxAdapterResponseParameters, context, new NativeAdViewListener(maxAdapterResponseParameters, maxAdFormat, context, maxAdViewAdapterListener));
} else {
final AdViewAdListener adViewAdListener = new AdViewAdListener(label, maxAdViewAdapterListener);
final BannerAdConfig bannerAdConfig = new BannerAdConfig();
AdConfig.AdSize vungleAdSize = vungleAdSize(maxAdFormat);
bannerAdConfig.setAdSize(vungleAdSize);
Bundle serverParameters = maxAdapterResponseParameters.getServerParameters();
if (serverParameters.containsKey("is_muted")) {
bannerAdConfig.setMuted(serverParameters.getBoolean("is_muted"));
}
if (isValidString) {
if (Banners.canPlayAd(thirdPartyAdPlacementId, bidResponse, vungleAdSize)) {
showAdViewAd(maxAdFormat, bannerAdConfig, maxAdapterResponseParameters, maxAdViewAdapterListener, adViewAdListener);
return;
}
} else if (Banners.canPlayAd(thirdPartyAdPlacementId, vungleAdSize)) {
showAdViewAd(maxAdFormat, bannerAdConfig, maxAdapterResponseParameters, maxAdViewAdapterListener, adViewAdListener);
return;
}
updateUserPrivacySettings(maxAdapterResponseParameters);
LoadAdCallback loadAdCallback = new LoadAdCallback() {
@Override
public void onAdLoad(String str) {
VungleMediationAdapter.this.showAdViewAd(maxAdFormat, bannerAdConfig, maxAdapterResponseParameters, maxAdViewAdapterListener, adViewAdListener);
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log(label + " ad for placement " + str + " failed to load with error: " + maxError);
maxAdViewAdapterListener.onAdViewAdLoadFailed(maxError);
}
};
if (isValidString) {
Banners.loadBanner(thirdPartyAdPlacementId, bidResponse, bannerAdConfig, loadAdCallback);
} else {
Banners.loadBanner(thirdPartyAdPlacementId, bannerAdConfig, loadAdCallback);
}
}
}
@Override
public void loadAppOpenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, final MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Loading ");
sb.append(isValidString ? "bidding " : "");
sb.append("app open ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (!Vungle.isInitialized()) {
log("Vungle SDK not successfully initialized: failing app open ad load...");
maxAppOpenAdapterListener.onAppOpenAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
} else if (!isValidPlacement(maxAdapterResponseParameters)) {
log("App open ad failed to load due to an invalid placement id: " + thirdPartyAdPlacementId);
maxAppOpenAdapterListener.onAppOpenAdLoadFailed(MaxAdapterError.INVALID_CONFIGURATION);
} else {
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
log("App open ad loaded");
maxAppOpenAdapterListener.onAppOpenAdLoaded();
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
log("App open ad loaded");
maxAppOpenAdapterListener.onAppOpenAdLoaded();
return;
}
updateUserPrivacySettings(maxAdapterResponseParameters);
loadFullscreenAd(maxAdapterResponseParameters, getContext(activity), new LoadAdCallback() {
@Override
public void onAdLoad(String str) {
VungleMediationAdapter.this.log("App open ad loaded");
maxAppOpenAdapterListener.onAppOpenAdLoaded();
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("App open ad for placement " + str + " failed to load with error: " + maxError);
maxAppOpenAdapterListener.onAppOpenAdLoadFailed(maxError);
}
});
}
}
@Override
public void loadInterstitialAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, final MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Loading ");
sb.append(isValidString ? "bidding " : "");
sb.append("interstitial ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (!Vungle.isInitialized()) {
log("Vungle SDK not successfully initialized: failing interstitial ad load...");
maxInterstitialAdapterListener.onInterstitialAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
} else if (!isValidPlacement(maxAdapterResponseParameters)) {
log("Interstitial ad failed to load due to an invalid placement id: " + thirdPartyAdPlacementId);
maxInterstitialAdapterListener.onInterstitialAdLoadFailed(MaxAdapterError.INVALID_CONFIGURATION);
} else {
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
log("Interstitial ad loaded");
maxInterstitialAdapterListener.onInterstitialAdLoaded();
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
log("Interstitial ad loaded");
maxInterstitialAdapterListener.onInterstitialAdLoaded();
return;
}
updateUserPrivacySettings(maxAdapterResponseParameters);
loadFullscreenAd(maxAdapterResponseParameters, getContext(activity), new LoadAdCallback() {
@Override
public void onAdLoad(String str) {
VungleMediationAdapter.this.log("Interstitial ad loaded");
maxInterstitialAdapterListener.onInterstitialAdLoaded();
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Interstitial ad for placement " + str + " failed to load with error: " + maxError);
maxInterstitialAdapterListener.onInterstitialAdLoadFailed(maxError);
}
});
}
}
@Override
public void loadNativeAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxNativeAdAdapterListener maxNativeAdAdapterListener) {
boolean isValidString = AppLovinSdkUtils.isValidString(maxAdapterResponseParameters.getBidResponse());
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Loading ");
sb.append(isValidString ? "bidding " : "");
sb.append("native ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (!Vungle.isInitialized()) {
log("Vungle SDK not successfully initialized: failing interstitial ad load...");
maxNativeAdAdapterListener.onNativeAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
} else if (isValidPlacement(maxAdapterResponseParameters)) {
Context context = getContext(activity);
loadVungleNativeAd(maxAdapterResponseParameters, context, new NativeAdListener(maxAdapterResponseParameters, context, maxNativeAdAdapterListener));
} else {
log("Native ad failed to load due to an invalid placement id: " + thirdPartyAdPlacementId);
maxNativeAdAdapterListener.onNativeAdLoadFailed(MaxAdapterError.INVALID_CONFIGURATION);
}
}
@Override
public void loadRewardedAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, final MaxRewardedAdapterListener maxRewardedAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Loading ");
sb.append(isValidString ? "bidding " : "");
sb.append("rewarded ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (!Vungle.isInitialized()) {
log("Vungle SDK not successfully initialized: failing rewarded ad load...");
maxRewardedAdapterListener.onRewardedAdLoadFailed(MaxAdapterError.NOT_INITIALIZED);
} else if (!isValidPlacement(maxAdapterResponseParameters)) {
log("Rewarded ad failed to load due to an invalid placement id: " + thirdPartyAdPlacementId);
maxRewardedAdapterListener.onRewardedAdLoadFailed(MaxAdapterError.INVALID_CONFIGURATION);
} else {
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
log("Rewarded ad loaded");
maxRewardedAdapterListener.onRewardedAdLoaded();
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
log("Rewarded ad loaded");
maxRewardedAdapterListener.onRewardedAdLoaded();
return;
}
updateUserPrivacySettings(maxAdapterResponseParameters);
loadFullscreenAd(maxAdapterResponseParameters, getContext(activity), new LoadAdCallback() {
@Override
public void onAdLoad(String str) {
VungleMediationAdapter.this.log("Rewarded ad loaded");
maxRewardedAdapterListener.onRewardedAdLoaded();
}
@Override
public void onError(String str, VungleException vungleException) {
MaxAdapterError maxError = VungleMediationAdapter.toMaxError(vungleException);
VungleMediationAdapter vungleMediationAdapter = VungleMediationAdapter.this;
vungleMediationAdapter.log("Rewarded ad for placement " + str + " failed to load with error: " + maxError);
maxRewardedAdapterListener.onRewardedAdLoadFailed(maxError);
}
});
}
}
@Override
public void onDestroy() {
VungleBanner vungleBanner = this.adViewAd;
if (vungleBanner != null) {
vungleBanner.destroyAd();
this.adViewAd = null;
}
NativeAd nativeAd = this.nativeAd;
if (nativeAd != null) {
nativeAd.unregisterView();
this.nativeAd.destroy();
this.nativeAd = null;
}
}
@Override
public void showAppOpenAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxAppOpenAdapterListener maxAppOpenAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Showing ");
sb.append(isValidString ? "bidding " : "");
sb.append("app open ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
Context context = getContext(activity);
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
showFullscreenAd(maxAdapterResponseParameters, context, new AppOpenAdListener(maxAppOpenAdapterListener));
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
showFullscreenAd(maxAdapterResponseParameters, context, new AppOpenAdListener(maxAppOpenAdapterListener));
return;
}
log("App open ad not ready");
maxAppOpenAdapterListener.onAppOpenAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "App open ad not ready"));
}
@Override
public void showInterstitialAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxInterstitialAdapterListener maxInterstitialAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Showing ");
sb.append(isValidString ? "bidding " : "");
sb.append("interstitial ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
showFullscreenAd(maxAdapterResponseParameters, getContext(activity), new InterstitialAdListener(maxInterstitialAdapterListener));
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
showFullscreenAd(maxAdapterResponseParameters, getContext(activity), new InterstitialAdListener(maxInterstitialAdapterListener));
return;
}
log("Interstitial ad not ready");
maxInterstitialAdapterListener.onInterstitialAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "Interstitial ad not ready"));
}
@Override
public void showRewardedAd(MaxAdapterResponseParameters maxAdapterResponseParameters, Activity activity, MaxRewardedAdapterListener maxRewardedAdapterListener) {
String bidResponse = maxAdapterResponseParameters.getBidResponse();
boolean isValidString = AppLovinSdkUtils.isValidString(bidResponse);
String thirdPartyAdPlacementId = maxAdapterResponseParameters.getThirdPartyAdPlacementId();
StringBuilder sb = new StringBuilder("Showing ");
sb.append(isValidString ? "bidding " : "");
sb.append("rewarded ad for placement: ");
sb.append(thirdPartyAdPlacementId);
sb.append(APSSharedUtil.TRUNCATE_SEPARATOR);
log(sb.toString());
if (isValidString) {
if (Vungle.canPlayAd(thirdPartyAdPlacementId, bidResponse)) {
configureReward(maxAdapterResponseParameters);
showFullscreenAd(maxAdapterResponseParameters, getContext(activity), new RewardedAdListener(maxRewardedAdapterListener));
return;
}
} else if (Vungle.canPlayAd(thirdPartyAdPlacementId)) {
configureReward(maxAdapterResponseParameters);
showFullscreenAd(maxAdapterResponseParameters, getContext(activity), new RewardedAdListener(maxRewardedAdapterListener));
return;
}
log("Rewarded ad not ready");
maxRewardedAdapterListener.onRewardedAdDisplayFailed(new MaxAdapterError(MaxAdapterError.ERROR_CODE_AD_DISPLAY_FAILED, "Ad Display Failed", 0, "Rewarded ad not ready"));
}
}