Search in sources :

Example 6 with AdException

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

the class ViewPool method getUnoccupiedView.

// Q: why are we keeping it in occupied? Should we not put/get from unoccupied directly?
// A: Because, when a videoCreativeView is created, we will have to, anyways, add the view to the occupied bucket as it is going to be given to adView.
// So, do that step here itself.(distribution of work!)
public View getUnoccupiedView(Context context, VideoCreativeViewListener videoCreativeViewListener, AdConfiguration.AdUnitIdentifierType adType, InterstitialManager interstitialManager) throws AdException {
    if (context == null) {
        throw new AdException(AdException.INTERNAL_ERROR, "Context is null");
    }
    if (mUnoccupiedViews != null && mUnoccupiedViews.size() > 0) {
        View view = mUnoccupiedViews.get(0);
        Views.removeFromParent(view);
        // get item from unoccupied & add it to occupied
        swapToOccupied(view);
        return mOccupiedViews.get(mOccupiedViews.size() - 1);
    }
    switch(adType) {
        case BANNER:
            plugPlayView = new PrebidWebViewBanner(context, interstitialManager);
            break;
        case INTERSTITIAL:
            plugPlayView = new PrebidWebViewInterstitial(context, interstitialManager);
            // add it to occupied
            break;
        case VAST:
            plugPlayView = new ExoPlayerView(context, videoCreativeViewListener);
            break;
    }
    addToOccupied(plugPlayView);
    return plugPlayView;
}
Also used : PrebidWebViewInterstitial(org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial) PrebidWebViewBanner(org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner) ExoPlayerView(org.prebid.mobile.rendering.video.ExoPlayerView) View(android.view.View) ExoPlayerView(org.prebid.mobile.rendering.video.ExoPlayerView) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 7 with AdException

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

the class AdBaseDialog method applyOrientation.

private void applyOrientation() throws AdException {
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    if (mForceOrientation == OrientationManager.ForcedOrientation.none) {
        if (mAllowOrientationChange) {
            // If screen orientation can be changed, an orientation of NONE means that any
            // orientation lock should be removed
            unApplyOrientation();
        } else {
            if (getActivity() == null) {
                throw new AdException(AdException.INTERNAL_ERROR, "Unable to set MRAID expand orientation to " + "'none'; expected passed in Activity Context.");
            }
            // If screen orientation cannot be changed and we can obtain the current
            // screen orientation, locking it to the current orientation is a best effort
            int orientation = deviceManager.getDeviceOrientation();
            lockOrientation(orientation);
        }
    } else {
        // Otherwise, we have a valid, non-NONE orientation. Lock the screen based on this value
        lockOrientation(mForceOrientation.getActivityInfoOrientation());
    }
}
Also used : DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 8 with AdException

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

the class BidLoader method failedToLoadBid.

private void failedToLoadBid(String msg) {
    LogUtil.error(TAG, "Invalid bid response: " + msg);
    mCurrentlyLoading.set(false);
    if (mRequestListener == null) {
        LogUtil.warn(TAG, "onFailedToLoad: Listener is null.");
        cancelRefresh();
        return;
    }
    setupRefreshTimer();
    mRequestListener.onError(new AdException(AdException.INTERNAL_ERROR, "Invalid bid response: " + msg));
}
Also used : AdException(org.prebid.mobile.rendering.errors.AdException)

Example 9 with AdException

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

the class AdViewManagerTest method whenFetchedWithException_callFailedToLoad.

@Test
public void whenFetchedWithException_callFailedToLoad() {
    AdException adException = new AdException(AdException.INTERNAL_ERROR, "Error message");
    mAdViewManager.onFetchingFailed(adException);
    ArgumentCaptor exceptionCaptor = ArgumentCaptor.forClass(AdException.class);
    verify(mMockAdViewListener).failedToLoad((AdException) exceptionCaptor.capture());
    assertEquals("SDK internal error: Error message", ((AdException) exceptionCaptor.getValue()).getMessage());
}
Also used : ArgumentCaptor(org.mockito.ArgumentCaptor) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 10 with AdException

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

the class BaseAdViewTest method setUp.

@Before
public void setUp() throws Exception {
    mMockContext = spy(Robolectric.buildActivity(Activity.class).create().get());
    mBaseAdView = new BaseAdView(mMockContext) {

        @Override
        protected void notifyErrorListeners(AdException adException) {
        }
    };
    mMockAdViewManager = Mockito.mock(AdViewManager.class);
    when(mMockAdViewManager.getAdConfiguration()).thenReturn(new AdConfiguration());
    Field field = WhiteBox.field(BaseAdView.class, "mAdViewManager");
    field.set(mBaseAdView, mMockAdViewManager);
}
Also used : Field(java.lang.reflect.Field) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) AdException(org.prebid.mobile.rendering.errors.AdException) AdViewManager(org.prebid.mobile.rendering.views.AdViewManager) Before(org.junit.Before)

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