use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class PrebidRewardedAdapter method loadRewardedAd.
@Override
public void loadRewardedAd(@NonNull MediationRewardedAdConfiguration adConfiguration, @NonNull MediationAdLoadCallback<MediationRewardedAd, MediationRewardedAdCallback> callback) {
Bundle serverParameters = adConfiguration.getServerParameters();
String adMobParameters = serverParameters.getString("parameter");
String adMobClassName = serverParameters.getString("class_name");
if (!adMobClassName.equals(CLASS_NAME)) {
String error = "Class name is different";
callback.onFailure(new AdError(1001, error, "prebid"));
return;
}
String responseId = adConfiguration.getMediationExtras().getString(EXTRA_RESPONSE_ID);
if (responseId == null) {
String error = "Empty response id";
callback.onFailure(new AdError(1002, error, "prebid"));
return;
}
HashMap<String, String> prebidParameters = BidResponseCache.getInstance().getKeywords(responseId);
if (prebidParameters == null) {
String error = "Prebid keywords are empty";
callback.onFailure(new AdError(1003, error, "prebid"));
return;
}
if (!ParametersMatcher.doParametersMatch(adMobParameters, prebidParameters)) {
String error = "Parameters are different";
callback.onFailure(new AdError(1004, error, "prebid"));
return;
}
try {
InterstitialControllerListener listener = getListener(callback);
interstitialController = new InterstitialController(adConfiguration.getContext(), listener);
interstitialController.loadAd(responseId, true);
} catch (AdException e) {
String error = "Exception in Prebid interstitial controller (" + e.getMessage() + ")";
Log.e(TAG, error);
callback.onFailure(new AdError(1005, error, "prebid"));
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class BannerView method displayAdServerView.
private void displayAdServerView(View view) {
removeAllViews();
if (view == null) {
notifyErrorListener(new AdException(AdException.INTERNAL_ERROR, "Failed to displayAdServerView. Provided view is null"));
return;
}
Views.removeFromParent(view);
addView(view);
if (mBannerViewListener != null) {
mBannerViewListener.onAdDisplayed(BannerView.this);
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class VastParserExtractor method failedToLoadAd.
private void failedToLoadAd(String msg) {
LogUtil.error(TAG, "Invalid ad response: " + msg);
final AdException adException = new AdException(AdException.INTERNAL_ERROR, "Invalid ad response: " + msg);
mListener.onResult(createExtractorFailureResult(adException));
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class HTMLCreative method load.
@Override
public void load() throws AdException {
if (mContextReference == null || mContextReference.get() == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Context is null. Could not load adHtml");
}
CreativeModel model = getCreativeModel();
AdConfiguration.AdUnitIdentifierType adType = model.getAdConfiguration().getAdUnitIdentifierType();
if (model.getAdConfiguration().isBuiltInVideo()) {
adType = AdConfiguration.AdUnitIdentifierType.BANNER;
}
if (adType == null) {
throw new AdException(AdException.INTERNAL_ERROR, "Can't create a WebView for a null adtype");
}
// create a webview here
PrebidWebViewBase prebidWebView = null;
if (adType == AdConfiguration.AdUnitIdentifierType.BANNER) {
// do all banner
prebidWebView = (PrebidWebViewBanner) ViewPool.getInstance().getUnoccupiedView(mContextReference.get(), null, adType, mInterstitialManager);
} else if (adType == AdConfiguration.AdUnitIdentifierType.INTERSTITIAL) {
// do all interstitials
prebidWebView = (PrebidWebViewInterstitial) ViewPool.getInstance().getUnoccupiedView(mContextReference.get(), null, adType, mInterstitialManager);
}
if (prebidWebView == null) {
throw new AdException(AdException.INTERNAL_ERROR, "PrebidWebView creation failed");
}
prebidWebView.setWebViewDelegate(this);
prebidWebView.setCreative(this);
String html = model.getHtml();
int width = model.getWidth();
int height = model.getHeight();
if (TextUtils.isEmpty(html)) {
String msg = "No HTML in creative data";
LogUtil.error(TAG, msg);
throw new AdException(AdException.SERVER_ERROR, msg);
} else {
html = injectingScriptContent(html);
prebidWebView.loadHTML(html, width, height);
setCreativeView(prebidWebView);
}
mIsEndCard = model.hasEndCard();
}
Aggregations