Search in sources :

Example 51 with AdException

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"));
    }
}
Also used : InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) Bundle(android.os.Bundle) InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 52 with AdException

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);
    }
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException)

Example 53 with AdException

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));
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException)

Example 54 with 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();
}
Also used : PrebidWebViewInterstitial(org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) AdException(org.prebid.mobile.rendering.errors.AdException)

Aggregations

AdException (org.prebid.mobile.rendering.errors.AdException)54 Test (org.junit.Test)25 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)7 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)6 AdError (com.google.android.gms.ads.AdError)5 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)5 Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)4 InterstitialControllerListener (org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener)4 CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)4 InterstitialManager (org.prebid.mobile.rendering.views.interstitial.InterstitialManager)4 Context (android.content.Context)2 Bundle (android.os.Bundle)2 NonNull (androidx.annotation.NonNull)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 InterstitialEventListener (org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener)2 RewardedVideoEventListener (org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener)2 VastExtractorResult (org.prebid.mobile.rendering.models.internal.VastExtractorResult)2