Search in sources :

Example 1 with PrebidWebViewInterstitial

use of org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial 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 2 with PrebidWebViewInterstitial

use of org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial in project prebid-mobile-android by prebid.

the class InterstitialManagerTest method displayViewAsInterstitialSuccess_ShowInterstitialAdView.

@Test
@LooperMode(LooperMode.Mode.PAUSED)
public void displayViewAsInterstitialSuccess_ShowInterstitialAdView() {
    VideoCreative mockVideoCreative = mock(VideoCreative.class);
    when(mockVideoCreative.isResolved()).thenReturn(true);
    BaseJSInterface mockJsInterface = mock(BaseJSInterface.class);
    when(mockJsInterface.getJsExecutor()).thenReturn(mock(JsExecutor.class));
    WebViewBase mockWebViewBase = mock(WebViewBase.class);
    when(mockWebViewBase.getMRAIDInterface()).thenReturn(mockJsInterface);
    PrebidWebViewInterstitial mockPrebidWebViewInterstitial = mock(PrebidWebViewInterstitial.class);
    when(mockPrebidWebViewInterstitial.getWebView()).thenReturn(mockWebViewBase);
    InterstitialView mockInterstitialView = mock(InterstitialView.class);
    when(mockInterstitialView.getCreativeView()).thenReturn(mockPrebidWebViewInterstitial);
    mSpyInterstitialManager.displayAdViewInInterstitial(mContext, mockInterstitialView);
    verify(mMockAdViewDelegate).showInterstitial();
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) PrebidWebViewInterstitial(org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial) VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) JsExecutor(org.prebid.mobile.rendering.views.webview.mraid.JsExecutor) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) Test(org.junit.Test) LooperMode(org.robolectric.annotation.LooperMode)

Example 3 with PrebidWebViewInterstitial

use of org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial 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)

Example 4 with PrebidWebViewInterstitial

use of org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial in project prebid-mobile-android by prebid.

the class InterstitialManager method showInterstitialDialog.

private void showInterstitialDialog(Context context, InterstitialView interstitialView) {
    WebViewBase webViewBase = ((PrebidWebViewInterstitial) interstitialView.getCreativeView()).getWebView();
    webViewBase.setId(INTERSTITIAL_WEBVIEW_ID);
    mInterstitialDialog = new AdInterstitialDialog(context, webViewBase, interstitialView, this);
    mInterstitialDialog.show();
}
Also used : PrebidWebViewInterstitial(org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) AdInterstitialDialog(org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)

Aggregations

PrebidWebViewInterstitial (org.prebid.mobile.rendering.views.webview.PrebidWebViewInterstitial)4 AdException (org.prebid.mobile.rendering.errors.AdException)2 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)2 View (android.view.View)1 Test (org.junit.Test)1 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 ExoPlayerView (org.prebid.mobile.rendering.video.ExoPlayerView)1 VideoCreative (org.prebid.mobile.rendering.video.VideoCreative)1 PrebidWebViewBanner (org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner)1 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)1 BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)1 JsExecutor (org.prebid.mobile.rendering.views.webview.mraid.JsExecutor)1 LooperMode (org.robolectric.annotation.LooperMode)1