@Override public void onAdImpression() { if(!isVideoAd){ omidAdSession.fireImpression(); } }
void stopOMIDAdSession(){ adWebView.omidAdSession.stopAdSession(); }
public String prependOMIDJSToHTML(String html) { if (!SDKSettings.getOMEnabled()) return html; try { String htmlString = html; if(!StringUtil.isEmpty(ANOmidViewabilty.getInstance().getOmidJsServiceContent())) { htmlString = ScriptInjector.injectScriptContentIntoHtml(ANOmidViewabilty.getInstance().getOmidJsServiceContent(), html); } return htmlString; } catch (Exception e) { e.printStackTrace(); // Return original HTML if there was an error return html; } }
public VideoAd(Context context, String inventoryCode, int memberID) { weakContext = new WeakReference<Context>(context); requestParameters = new UTRequestParameters(getContext()); requestParameters.setInventoryCodeAndMemberID(memberID, inventoryCode); requestParameters.setMediaType(MediaType.INSTREAM_VIDEO); mVideoAdFetcher = new VideoAdFetcher(this); // setting the period to -1 disables autorefresh mVideoAdFetcher.setPeriod(-1); dispatcher = new VideoAdViewDispatcher(); videoAdView = new InstreamVideoView(getContext()); this.setAllowedSizes(); ANOmidViewabilty.getInstance().activateOmidAndCreatePartner(context.getApplicationContext()); }
protected void success() { // Delay creation of AdSession till JS loads completely for WebView Video if(isVideoAd) { omidAdSession.initAdSession(AdWebView.this,isVideoAd); } if (caller_requester != null) { caller_requester.onReceiveAd(getAdResponse()); } }
public void initAdSession(WebView webView, boolean isVideoAd) { if (!SDKSettings.getOMEnabled()) return; try { String customReferenceData = ""; AdSessionContext adSessionContext = AdSessionContext.createHtmlAdSessionContext(ANOmidViewabilty.getInstance().getAppnexusPartner(), webView, customReferenceData); Owner owner = isVideoAd?Owner.JAVASCRIPT:Owner.NATIVE; AdSessionConfiguration adSessionConfiguration = AdSessionConfiguration.createAdSessionConfiguration(owner, isVideoAd?owner:null, false); omidAdSession = AdSession.createAdSession(adSessionConfiguration, adSessionContext); omidAdSession.registerAdView(webView); omidAdSession.start(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NullPointerException exception){ Clog.e(Clog.baseLogTag, "OMID Ad Session - Exception", exception); } }
@SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") protected void setup() { setWebChromeClient(new VideoChromeClient(owner)); setWebViewClient(new AdWebViewClient()); omidAdSession = new ANOmidAdSession(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setLayoutParams(params); }
public static ANOmidViewabilty getInstance() { if (omid_instance == null) { omid_instance = new ANOmidViewabilty(); Clog.v(Clog.baseLogTag, Clog.getString(R.string.init)); } return omid_instance; }
public void activateOmidAndCreatePartner(Context applicationContext) { // Activate OMID if it is already not if (!SDKSettings.getOMEnabled()) return; try { if (!Omid.isActive()) { Omid.activateWithOmidApiVersion(Omid.getVersion(), applicationContext); } } catch (IllegalArgumentException e) { e.printStackTrace(); } // If OMID active but partner is null then create partner if (Omid.isActive() && appnexusPartner == null) { try { appnexusPartner = Partner.createPartner(OMID_PARTNER_NAME, Settings.getSettings().sdkVersion); } catch (IllegalArgumentException e) { e.printStackTrace(); } } if (StringUtil.isEmpty(OMID_JS_SERVICE_CONTENT)) { try { fetchOmidJS(applicationContext); } catch (IOException e) { e.printStackTrace(); } } }
html = prependRawResources(html); html = prependViewPort(html); html = omidAdSession.prependOMIDJSToHTML(html); this.loadDataWithBaseURL(Settings.getBaseUrl(), html, "text/html", "UTF-8", null);
public VideoAd(Context context, String placementID) { weakContext = new WeakReference<Context>(context); requestParameters = new UTRequestParameters(getContext()); requestParameters.setPlacementID(placementID); requestParameters.setMediaType(MediaType.INSTREAM_VIDEO); mVideoAdFetcher = new VideoAdFetcher(this); // setting the period to -1 disables autorefresh mVideoAdFetcher.setPeriod(-1); dispatcher = new VideoAdViewDispatcher(); videoAdView = new InstreamVideoView(getContext()); this.setAllowedSizes(); ANOmidViewabilty.getInstance().activateOmidAndCreatePartner(context.getApplicationContext()); }
void stopOMIDAdSession(){ omidAdSession.stopAdSession(); }
omidAdSession.initAdSession(VideoWebView.this,true); if (paramsDictionary != null) { if (paramsDictionary.has("duration")) {
@SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") protected void setup() { implementation = new MRAIDImplementation(this); omidAdSession = new ANOmidAdSession(); setWebChromeClient(mWebChromeClient = new VideoEnabledWebChromeClient(this)); setWebViewClient(new AdWebViewClient()); }
adType = AdType.UNKNOWN; AdvertisingIDUtil.retrieveAndSetAAID(context); ANOmidViewabilty.getInstance().activateOmidAndCreatePartner(context.getApplicationContext());
@Override public void destroy() { if(mWebChromeClient != null){ mWebChromeClient.onHideCustomView(); } omidAdSession.stopAdSession(); // in case `this` was not removed when destroy was called ViewUtil.removeChildFromParent(this); try { super.destroy(); } // Fatal exception in android v4.x in TextToSpeech catch (IllegalArgumentException e) { Clog.e(Clog.baseLogTag, Clog.getString(R.string.apn_webview_failed_to_destroy), e); } this.removeAllViews(); stopCheckViewable(); }
@Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); String javascript = "javascript:window.mraid.util.pageFinished()"; if (!firstPageFinished) { injectJavaScript(javascript); if (isMRAIDEnabled) { implementation.webViewFinishedLoading(AdWebView.this, initialMraidStateString); startCheckViewable(); } // Send Back onAdLoaded. For Video Ads it will be sent after we have adReady from player if (isVideoAd && videoImplementation != null) { videoImplementation.webViewFinishedLoading(); } else if (!implementation.isMRAIDTwoPartExpanded) { Clog.i(Clog.baseLogTag, "AdWebView.onPageFinished -- !isMRAIDTwoPartExpanded seding back success"); AdWebView.this.success(); } if(!isVideoAd) { omidAdSession.initAdSession(AdWebView.this,isVideoAd); } firstPageFinished = true; } }