Search in sources :

Example 1 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class TwoPartExpandRunnable method run.

// NOTE: handleMRAIDEventsInCreative ACTION_EXPAND is invoked from a background thread.
// This means the webview instantiation should be performed from a UI thread.
@Override
public void run() {
    HTMLCreative htmlCreative = mWeakHtmlCreative.get();
    if (htmlCreative == null) {
        LogUtil.error(TAG, "HTMLCreative object is null");
        return;
    }
    PrebidWebViewBase prebidWebViewBanner = new PrebidWebViewBanner(mOldWebViewBase.getContext(), mMraidController.mInterstitialManager);
    // inject mraid.js & load url here, for 2part expand
    prebidWebViewBanner.setOldWebView(mOldWebViewBase);
    prebidWebViewBanner.initTwoPartAndLoad(mMraidEvent.mraidActionHelper);
    prebidWebViewBanner.setWebViewDelegate(htmlCreative);
    prebidWebViewBanner.setCreative(htmlCreative);
    // Set a view before handling any action.
    htmlCreative.setCreativeView(prebidWebViewBanner);
    htmlCreative.setTwoPartNewWebViewBase(prebidWebViewBanner);
    mMraidController.expand(mOldWebViewBase, prebidWebViewBanner, mMraidEvent);
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) PrebidWebViewBanner(org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 2 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative 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 3 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class PrebidWebViewBannerTest method loadHTMLTest.

@Test
public void loadHTMLTest() throws IOException {
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    CreativeModel mockCreativeModel = mock(CreativeModel.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getHtml()).thenReturn(ResourceUtils.convertResourceToString("ad_contains_iframe"));
    when(mockCreativeModel.getAdConfiguration()).thenReturn(new AdConfiguration());
    mBanner.mCreative = mockCreative;
    mBanner.loadHTML(mAdHTML, 100, 200);
    assertNotNull(mBanner.mWebView);
    assertEquals("1part", mBanner.mWebView.mMRAIDBridgeName);
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 4 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class MraidControllerTest method callControllerHandler.

private void callControllerHandler(MraidEvent event) {
    final HTMLCreative mockCreative = mock(HTMLCreative.class);
    final CreativeModel mockCreativeModel = mock(CreativeModel.class);
    final WebViewBase mockOldWebView = mock(WebViewBase.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getAdConfiguration()).thenReturn(mock(AdConfiguration.class));
    when(mockOldWebView.getContext()).thenReturn(mContext);
    mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative)

Example 5 with HTMLCreative

use of org.prebid.mobile.rendering.models.HTMLCreative in project prebid-mobile-android by prebid.

the class MraidControllerTest method handleMraidEventWhenUnloadEvent_CallCreativeCompleteAndClose.

@Test
public void handleMraidEventWhenUnloadEvent_CallCreativeCompleteAndClose() {
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    CreativeViewListener mockListener = mock(CreativeViewListener.class);
    when(mockCreative.getCreativeViewListener()).thenReturn(mockListener);
    mMraidController.handleMraidEvent(createMraidEvent(JSInterface.ACTION_UNLOAD, null), mockCreative, mock(WebViewBase.class), mock(PrebidWebViewBase.class));
    verify(mMockInterstitialManager).interstitialClosed(any(View.class));
    verify(mockListener).creativeDidComplete(mockCreative);
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) CreativeViewListener(org.prebid.mobile.rendering.listeners.CreativeViewListener) View(android.view.View) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Aggregations

HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)14 Test (org.junit.Test)8 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)7 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)5 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)3 View (android.view.View)2 CreativeModel (org.prebid.mobile.rendering.models.CreativeModel)2 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)2 Handler (android.os.Handler)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 AdException (org.prebid.mobile.rendering.errors.AdException)1 AdInterstitialDialog (org.prebid.mobile.rendering.interstitial.AdInterstitialDialog)1 CreativeViewListener (org.prebid.mobile.rendering.listeners.CreativeViewListener)1 Transaction (org.prebid.mobile.rendering.loading.Transaction)1 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)1 MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)1 MraidEventHandlerNotifierRunnable (org.prebid.mobile.rendering.mraid.methods.MraidEventHandlerNotifierRunnable)1 RedirectUrlListener (org.prebid.mobile.rendering.mraid.methods.network.RedirectUrlListener)1 PrebidWebViewBanner (org.prebid.mobile.rendering.views.webview.PrebidWebViewBanner)1