com.mopub.nativeads.BaseNativeAd Java Examples
The following examples show how to use
com.mopub.nativeads.BaseNativeAd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MoPubNativeAdResponse.java From mobile-sdk-android with Apache License 2.0 | 5 votes |
boolean setResources(NativeAd response) { if (response != null) { this.mopubNativeAd = response; BaseNativeAd baseNativeAd = response.getBaseNativeAd(); if (!(baseNativeAd instanceof StaticNativeAd)) { return false; } final StaticNativeAd staticNativeAd = (StaticNativeAd) baseNativeAd; this.title = staticNativeAd.getTitle(); this.description = staticNativeAd.getText(); this.imageUrl = staticNativeAd.getMainImageUrl(); this.iconUrl = staticNativeAd.getIconImageUrl(); this.callToAction = staticNativeAd.getCallToAction(); if (staticNativeAd.getStarRating() != null) { this.rating = new Rating(staticNativeAd.getStarRating(), 5.0); } if (!staticNativeAd.getExtras().isEmpty()) { // put extras in native response, MoPub returns String as Object for (Map.Entry<String, Object> entry : staticNativeAd.getExtras().entrySet()) { nativeElements.put(entry.getKey(), entry.getValue()); } } nativeElements.put(NATIVE_ELEMENT_OBJECT, response); if (staticNativeAd.getPrivacyInformationIconImageUrl() != null) { nativeElements.put(MoPubNativeSettings.KEY_PRIVACYINFO_ICONURL, staticNativeAd.getPrivacyInformationIconImageUrl()); } if (staticNativeAd.getPrivacyInformationIconClickThroughUrl() != null) { nativeElements.put(MoPubNativeSettings.KEY_PRIVACYINFO_LINKURL, staticNativeAd.getPrivacyInformationIconClickThroughUrl()); } return true; } return false; }
Example #2
Source File: TwitterStaticNativeAdRenderer.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Override public boolean supports(final BaseNativeAd nativeAd) { return nativeAd instanceof StaticNativeAd; }
Example #3
Source File: TwitterStaticNativeAdRendererTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testSupports_withCorrectInstanceOfBaseNativeAd_shouldReturnTrue() throws Exception { assertTrue(twitterStaticNativeAdRenderer.supports(new StaticNativeAd() {})); assertFalse(twitterStaticNativeAdRenderer.supports(mock(BaseNativeAd.class))); }