Skip to content

Instantly share code, notes, and snippets.

@ayltai
Created February 12, 2017 09:56
Show Gist options
  • Save ayltai/983a2c1384615bb6f02dbb0036aff605 to your computer and use it in GitHub Desktop.
Save ayltai/983a2c1384615bb6f02dbb0036aff605 to your computer and use it in GitHub Desktop.
Populating ad fields
this.setTitle(this.nativeAd.getAdTitle());
this.setText(this.nativeAd.getAdBody());
final NativeAd.Image coverImage = this.nativeAd.getAdCoverImage();
if (coverImage != null) this.setMainImageUrl(coverImage.getUrl());
final NativeAd.Image icon = this.nativeAd.getAdIcon();
if (icon != null) this.setIconImageUrl(icon.getUrl());
this.setCallToAction(this.nativeAd.getAdCallToAction());
this.setStarRating(FacebookNativeAd.getStarRatingValue(this.nativeAd.getAdStarRating()));
this.addExtra(FacebookNativeAd.SOCIAL_CONTEXT_FOR_AD, this.nativeAd.getAdSocialContext());
final NativeAd.Image adChoicesIconImage = this.nativeAd.getAdChoicesIcon();
if (adChoicesIconImage != null) {
this.setPrivacyInformationIconImageUrl(adChoicesIconImage.getUrl());
this.setPrivacyInformationIconClickThroughUrl(this.nativeAd.getAdChoicesLinkUrl());
}
this.preCacheImages(this.getImageUrls());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment