Search in sources :

Example 1 with AdException

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

the class VastParserExtractor method performVastUnwrap.

private void performVastUnwrap(String vast) {
    if (!vast.contains("VAST version")) {
        final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.VAST_SCHEMA_ERROR.toString());
        mListener.onResult(createExtractorFailureResult(adException));
        return;
    }
    mVastWrapperCount++;
    // A new response has come back, either from the initial VAST request or a wrapper request.
    // Parse the response.
    AdResponseParserVast adResponseParserVast;
    try {
        adResponseParserVast = new AdResponseParserVast(vast);
    } catch (VastParseError e) {
        LogUtil.error(TAG, "AdResponseParserVast creation failed: " + Log.getStackTraceString(e));
        final AdException adException = new AdException(AdException.INTERNAL_ERROR, e.getMessage());
        mListener.onResult(createExtractorFailureResult(adException));
        return;
    }
    // Check if this is the response from the initial request or from unwrapping a wrapper
    if (mRootVastParser == null) {
        // If mRootVastParser doesn't exist then it is the initial VAST request
        LogUtil.debug(TAG, "Initial VAST Request");
        mRootVastParser = adResponseParserVast;
    } else {
        // Otherwise, this is the result of unwrapping a Wrapper.
        LogUtil.debug(TAG, "Unwrapping VAST Wrapper");
        mLatestVastWrapperParser.setWrapper(adResponseParserVast);
    }
    mLatestVastWrapperParser = adResponseParserVast;
    // Check if this response is a wrapper
    String vastUrl = mLatestVastWrapperParser.getVastUrl();
    if (!TextUtils.isEmpty(vastUrl)) {
        if (mVastWrapperCount >= WRAPPER_NESTING_LIMIT) {
            final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.WRAPPER_LIMIT_REACH_ERROR.toString());
            final VastExtractorResult extractorFailureResult = createExtractorFailureResult(adException);
            mListener.onResult(extractorFailureResult);
            mVastWrapperCount = 0;
            return;
        }
        mAsyncVastLoader.loadVast(vastUrl, mResponseHandler);
    } else {
        final AdResponseParserBase[] parserArray = { mRootVastParser, mLatestVastWrapperParser };
        mListener.onResult(new VastExtractorResult(parserArray));
    }
}
Also used : VastParseError(org.prebid.mobile.rendering.errors.VastParseError) AdResponseParserBase(org.prebid.mobile.rendering.parser.AdResponseParserBase) AdResponseParserVast(org.prebid.mobile.rendering.parser.AdResponseParserVast) VastExtractorResult(org.prebid.mobile.rendering.models.internal.VastExtractorResult) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 2 with AdException

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

the class CreativeFactory method attemptVastCreative.

private void attemptVastCreative() {
    VideoCreativeModel videoCreativeModel = (VideoCreativeModel) mCreativeModel;
    String mediaUrl = videoCreativeModel.getMediaUrl();
    if (Utils.isBlank(mediaUrl) || mediaUrl.equals("invalid media file")) {
        mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.NO_SUPPORTED_MEDIA_ERROR.toString()));
        return;
    }
    // get the tracking url for all event types & do the registration here.
    for (VideoAdEvent.Event videoEvent : VideoAdEvent.Event.values()) {
        videoCreativeModel.registerVideoEvent(videoEvent, videoCreativeModel.getVideoEventUrls().get(videoEvent));
    }
    VideoCreative newCreative;
    try {
        if (mCreativeModel.getAdConfiguration().isRewarded()) {
            newCreative = new RewardedVideoCreative(mContextReference.get(), videoCreativeModel, mOmAdSessionManager, mInterstitialManager);
        } else {
            newCreative = new VideoCreative(mContextReference.get(), videoCreativeModel, mOmAdSessionManager, mInterstitialManager);
        }
        newCreative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
        mCreative = newCreative;
        markWorkStart(VAST_TIMEOUT);
        newCreative.load();
    } catch (Exception exception) {
        LogUtil.error(TAG, "VideoCreative creation failed: " + Log.getStackTraceString(exception));
        mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, "VideoCreative creation failed: " + exception.getMessage()));
    }
}
Also used : RewardedVideoCreative(org.prebid.mobile.rendering.video.RewardedVideoCreative) VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) RewardedVideoCreative(org.prebid.mobile.rendering.video.RewardedVideoCreative) VideoAdEvent(org.prebid.mobile.rendering.video.VideoAdEvent) AdException(org.prebid.mobile.rendering.errors.AdException) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 3 with AdException

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

the class CreativeFactory method start.

public void start() {
    try {
        AdConfiguration.AdUnitIdentifierType adUnitIdentifierType = mCreativeModel.getAdConfiguration().getAdUnitIdentifierType();
        switch(adUnitIdentifierType) {
            case BANNER:
            case INTERSTITIAL:
                attemptAuidCreative();
                break;
            case VAST:
                attemptVastCreative();
                break;
            default:
                String msg = "Unable to start creativeFactory. adConfig.adUnitIdentifierType doesn't match supported types" + "adConfig.adUnitIdentifierType: " + adUnitIdentifierType;
                LogUtil.error(TAG, msg);
                AdException adException = new AdException(AdException.INTERNAL_ERROR, msg);
                mListener.onFailure(adException);
                break;
        }
    } catch (Exception exception) {
        String message = "Creative Factory failed: " + exception.getMessage();
        LogUtil.error(TAG, message + Log.getStackTraceString(exception));
        AdException adException = new AdException(AdException.INTERNAL_ERROR, message);
        mListener.onFailure(adException);
    }
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) AdException(org.prebid.mobile.rendering.errors.AdException) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 4 with AdException

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

the class CreativeFactory method attemptAuidCreative.

private void attemptAuidCreative() throws Exception {
    mCreative = new HTMLCreative(mContextReference.get(), mCreativeModel, mOmAdSessionManager, mInterstitialManager);
    mCreative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
    ArrayList<String> riUrls = new ArrayList<>();
    ArrayList<String> rcUrls = new ArrayList<>();
    // This needs to be more generalized and allow for multiple click urls
    if (!mCreativeModel.isRequireImpressionUrl() || Utils.isNotBlank(mCreativeModel.getImpressionUrl())) {
        if (!TextUtils.isEmpty(mCreativeModel.getImpressionUrl())) {
            riUrls.add(mCreativeModel.getImpressionUrl());
            mCreativeModel.registerTrackingEvent(TrackingEvent.Events.IMPRESSION, riUrls);
        }
        // 
        if (!TextUtils.isEmpty(mCreativeModel.getClickUrl())) {
            rcUrls.add(mCreativeModel.getClickUrl());
            mCreativeModel.registerTrackingEvent(TrackingEvent.Events.CLICK, rcUrls);
        }
    } else {
        mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, "Tracking info not found"));
    }
    markWorkStart(BANNER_TIMEOUT);
    mCreative.load();
}
Also used : ArrayList(java.util.ArrayList) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 5 with AdException

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

the class Transaction method startCreativeFactories.

public void startCreativeFactories() {
    try {
        // Initialize list of CreativeFactories
        mCreativeFactories.clear();
        for (CreativeModel creativeModel : mCreativeModels) {
            CreativeFactory creativeFactory = new CreativeFactory(mContextReference.get(), creativeModel, new CreativeFactoryListener(this), mOmAdSessionManager, mInterstitialManager);
            mCreativeFactories.add(creativeFactory);
        }
        // Start first CreativeFactory, if any
        // On success, the CreativeFactoryListener will start the next CreativeFactory
        mCreativeFactoryIterator = mCreativeFactories.iterator();
        startNextCreativeFactory();
    } catch (AdException e) {
        mListener.onTransactionFailure(e, mLoaderIdentifier);
    }
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) 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