Search in sources :

Example 11 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class PrebidBannerAdapter method getListener.

@NonNull
private DisplayViewListener getListener(CustomEventBannerListener adMobListener) {
    return new DisplayViewListener() {

        @Override
        public void onAdLoaded() {
            adMobListener.onAdLoaded(adView);
        }

        @Override
        public void onAdDisplayed() {
        }

        @Override
        public void onAdFailed(AdException exception) {
            String message = exception.getMessage();
            if (message == null)
                message = "Failed to load DisplayView ad";
            adMobListener.onAdFailedToLoad(new AdError(1010, message, "prebid"));
        }

        @Override
        public void onAdClicked() {
            adMobListener.onAdClicked();
            adMobListener.onAdOpened();
        }

        @Override
        public void onAdClosed() {
            adMobListener.onAdClosed();
        }
    };
}
Also used : DisplayViewListener(org.prebid.mobile.rendering.bidding.listeners.DisplayViewListener) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException) NonNull(androidx.annotation.NonNull)

Example 12 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class PrebidRewardedAdapter method getListener.

private InterstitialControllerListener getListener(MediationAdLoadCallback<MediationRewardedAd, MediationRewardedAdCallback> adMobCallback) {
    return new InterstitialControllerListener() {

        @Override
        public void onInterstitialReadyForDisplay() {
            rewardedAdCallback = adMobCallback.onSuccess(context -> {
                interstitialController.show();
            });
        }

        @Override
        public void onInterstitialDisplayed() {
            rewardedAdCallback.onAdOpened();
            rewardedAdCallback.onVideoStart();
            rewardedAdCallback.reportAdImpression();
        }

        @Override
        public void onInterstitialClicked() {
            rewardedAdCallback.reportAdClicked();
        }

        @Override
        public void onInterstitialFailedToLoad(AdException exception) {
            String errorMessage = exception.getMessage() != null ? exception.getMessage() : "Failed to load ad";
            AdError adError = new AdError(1006, errorMessage, "prebid");
            adMobCallback.onFailure(adError);
            if (rewardedAdCallback != null) {
                rewardedAdCallback.onAdFailedToShow(adError);
            }
        }

        @Override
        public void onInterstitialClosed() {
            rewardedAdCallback.onVideoComplete();
            rewardedAdCallback.onAdClosed();
        }
    };
}
Also used : InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) RewardItem(com.google.android.gms.ads.rewarded.RewardItem) InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) Bundle(android.os.Bundle) AdException(org.prebid.mobile.rendering.errors.AdException) NonNull(androidx.annotation.NonNull) MediationRewardedAd(com.google.android.gms.ads.mediation.MediationRewardedAd) HashMap(java.util.HashMap) AdError(com.google.android.gms.ads.AdError) InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) Keep(androidx.annotation.Keep) BidResponseCache(org.prebid.mobile.rendering.bidding.display.BidResponseCache) MediationRewardedAdConfiguration(com.google.android.gms.ads.mediation.MediationRewardedAdConfiguration) MediationRewardedAdCallback(com.google.android.gms.ads.mediation.MediationRewardedAdCallback) MediationAdLoadCallback(com.google.android.gms.ads.mediation.MediationAdLoadCallback) Log(android.util.Log) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 13 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class InterstitialController method loadAd.

public void loadAd(String responseId, boolean isRewarded) {
    BidResponse bidResponse = BidResponseCache.getInstance().popBidResponse(responseId);
    if (bidResponse == null) {
        if (mListener != null) {
            mListener.onInterstitialFailedToLoad(new AdException(AdException.INTERNAL_ERROR, "No bid response found in the cache"));
        }
        return;
    }
    AdConfiguration adUnitConfiguration = new AdConfiguration();
    adUnitConfiguration.setRewarded(isRewarded);
    loadAd(adUnitConfiguration, bidResponse);
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 14 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class VideoView method init.

@Override
protected void init() throws AdException {
    try {
        super.init();
        setAdViewManagerValues();
        setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.black));
        registerEventBroadcast();
    } catch (Exception e) {
        throw new AdException(AdException.INIT_ERROR, "VideoAdView initialization failed: " + Log.getStackTraceString(e));
    }
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 15 with AdException

use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.

the class AdConfigurationTest method testAdConfiguration.

@Test
public void testAdConfiguration() {
    AdConfiguration adConfig = null;
    AdException err = null;
    adConfig = new AdConfiguration();
    assertNotNull(adConfig);
    assertNull(err);
    assertEquals(PrebidRenderingSettings.AUTO_REFRESH_DELAY_DEFAULT, adConfig.getAutoRefreshDelay());
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

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