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);
}
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();
}
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);
}
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));
}
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);
}
Aggregations