CSMSDKAdResponse csmAd = new CSMSDKAdResponse(width, height, adType, responseUrl, impressionUrls, creativeId); csmAd.setClassName(className); csmAd.setId(adId); csmAd.setParam(param); csmAd.setContentSource(UTConstants.CSM); adList.add(csmAd);
protected BaseAdResponse popAd() { if ((adList != null) && (adList.getFirst() != null)) { if (adList.getFirst().getContentSource() != null && adList.getFirst().getContentSource().equalsIgnoreCase("csm")){ CSMSDKAdResponse CSMSDKAdResponse = (CSMSDKAdResponse)adList.getFirst(); mediatedClasses.add(CSMSDKAdResponse.getClassName()); } return adList.removeFirst(); } return null; }
void fireImpressionTracker() { ArrayList<String> impressionTrackers = currentAd.getImpressionURLs(); // Just to be fail safe since we are making it to null below to mark it as beign used. if (impressionTrackers != null) { synchronized (impressionTrackers) { Context context = this.contextWeakReference.get(); // If not connected to network and impression trackerlist size is non zero queue them to be fired in future. if (context != null && !SharedNetworkManager.getInstance(context).isConnected(context) && impressionTrackers.size() > 0) { SharedNetworkManager nm = SharedNetworkManager.getInstance(context); for (String url : impressionTrackers) { nm.addURL(url, context); } } // else for all other cases when impression trackerlist size in non zero fire the trackers else if (impressionTrackers.size() > 0) { for (String url : impressionTrackers) { fireTracker(url); } } // Reset impression URL once we have either fired them all or added thme to SharedNewtorkManager Queue. currentAd.setImpressionURLs(null); } } }
/** * Tests no content csm banner response * * @throws Exception */ @Test public void testNoBannerCSMResponse() throws Exception { String bannerCSMString = TestResponsesUT.mediatedNoFillBanner(); utAdResponse = new UTAdResponse(bannerCSMString, null, MediaType.BANNER, "v"); assertNotNull(utAdResponse); LinkedList<BaseAdResponse> list = utAdResponse.getAdList(); assertNotNull(utAdResponse.getAdList()); System.out.println("Printing first"); CSMSDKAdResponse baseCSMSDKAdResponse = (CSMSDKAdResponse) list.getFirst(); assertEquals("csm", baseCSMSDKAdResponse.getContentSource()); assertNull(baseCSMSDKAdResponse.getAdContent()); assertEquals("44863345", baseCSMSDKAdResponse.getCreativeId()); }
} else { Clog.d(Clog.mediationLogTag, Clog.getString( R.string.instantiating_class, currentAd.getClassName())); Class<?> c = Class.forName(currentAd.getClassName()); MediatedNativeAd ad = (MediatedNativeAd) c.newInstance(); if (requester.getRequestParams() != null) { ad.requestNativeAd( requester.getRequestParams().getContext(), currentAd.getParam(), currentAd.getId(), this, requester.getRequestParams().getTargetingParameters()); } else { handleInstantiationFailure(e, currentAd.getClassName()); } catch (ClassCastException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (LinkageError e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (InstantiationException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (IllegalAccessException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (Exception e) { Clog.e(Clog.mediationLogTag, Clog.getString(R.string.mediated_request_exception), e);
/** * Tests csm & rtb banner response * * @throws Exception */ @Test public void testBannerCSMResponse() throws Exception { String bannerCSMString = TestResponsesUT.noFillCSM_RTBBanner(); utAdResponse = new UTAdResponse(bannerCSMString, null, MediaType.BANNER, "v"); assertNotNull(utAdResponse); LinkedList<BaseAdResponse> list = utAdResponse.getAdList(); assertNotNull(utAdResponse.getAdList()); System.out.println("Printing first"); CSMSDKAdResponse baseCSMSDKAdResponse = (CSMSDKAdResponse) list.getFirst(); assertEquals("csm", baseCSMSDKAdResponse.getContentSource()); assertEquals("44863345", baseCSMSDKAdResponse.getCreativeId()); System.out.println("Printing second"); BaseAdResponse baseAdResponse = (BaseAdResponse) list.getLast(); assertEquals("rtb", baseAdResponse.getContentSource()); assertEquals("6332753", baseAdResponse.getCreativeId()); }
private void handleCSMResponse(Ad ownerAd, CSMSDKAdResponse csmSdkAdResponse) { Clog.i(Clog.baseLogTag, "Mediation type is CSM, passing it to MediatedAdViewController."); if (csmSdkAdResponse.getAdType().equals(UTConstants.AD_TYPE_NATIVE)) { mediatedNativeAdController = MediatedNativeAdController.create(csmSdkAdResponse, AdViewRequestManager.this); } else { AdView owner = (AdView) ownerAd; if (owner.getMediaType().equals(MediaType.BANNER)) { controller = MediatedBannerAdViewController.create( (Activity) owner.getContext(), AdViewRequestManager.this, csmSdkAdResponse, owner.getAdDispatcher()); } else if (owner.getMediaType().equals(MediaType.INTERSTITIAL)) { controller = MediatedInterstitialAdViewController.create( (Activity) owner.getContext(), AdViewRequestManager.this, csmSdkAdResponse, owner.getAdDispatcher()); } else { Clog.e(Clog.baseLogTag, "MediaType type can not be identified."); continueWaterfall(ResultCode.INVALID_REQUEST); } } }
R.string.instantiating_class, currentAd.getClassName())); String className = currentAd.getClassName(); String intermediaryAdaptorClassName = Settings.getSettings().externalMediationClasses.get(className); Class<?> c; } catch (ClassNotFoundException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (LinkageError e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (InstantiationException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (IllegalAccessException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (ClassCastException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (NoSuchMethodException e) { handleInstantiationFailure(e, currentAd.getClassName()); } catch (InvocationTargetException e) { handleInstantiationFailure(e, currentAd.getClassName());