Skip to content

Instantly share code, notes, and snippets.

@tsiougkosn
Created March 15, 2016 15:12
Show Gist options
  • Save tsiougkosn/5c0aed278c0735c9d60e to your computer and use it in GitHub Desktop.
Save tsiougkosn/5c0aed278c0735c9d60e to your computer and use it in GitHub Desktop.
avocarrotCustom = new AvocarrotCustom(this, BuildConfig.AvocarrotApiKey, BuildConfig.PLACEMENT_CUSTOM);
avocarrotCustom.setSandbox(BuildConfig.SANDBOX);
avocarrotCustom.setLogger(true, "ALL");
avocarrotCustom.setListener(new AvocarrotCustomListener() {
@Override
public void onAdLoaded(List<CustomModel> ads) {
super.onAdLoaded(ads);
if ((ads==null)||(ads.size()==0))
return;
adview.setVisibility(View.VISIBLE);
final CustomModel ad = ads.get(0);
VideoView videoView = (VideoView) adview.findViewById(R.id.avo_native_video);
ImageView imageView = (ImageView) adview.findViewById(R.id.avo_native_image);
ImageView adIcon = (ImageView) adview.findViewById(R.id.avo_native_icon);
TextView adDescription = (TextView) adview.findViewById(R.id.avo_native_description);
TextView headline = (TextView) adview.findViewById(R.id.avo_native_headline);
Button adButton = (Button) adview.findViewById(R.id.avo_cta_button);
headline.setText(ad.getTitle());
adDescription.setText(ad.getDescription());
adButton.setText(ad.getCTAText());
avocarrotCustom.loadMedia(ad, imageView, videoView);
avocarrotCustom.loadIcon(ad, adIcon);
// Show ad on click
adButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
avocarrotCustom.handleClick(ad);
}
});
avocarrotCustom.bindView(ad, adview);
}
});
avocarrotCustom.loadAd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment