use of com.mopub.nativeads.StaticNativeAd in project prebid-mobile-android by prebid.
the class XandrNativeInAppMoPubDemoActivity method inflateMoPubNativeAd.
private void inflateMoPubNativeAd(NativeAd nativeAd) {
Log.d("Prebid", "came here");
final StaticNativeAd ad = (StaticNativeAd) nativeAd.getBaseNativeAd();
Log.d("Prebid", "" + ad.getExtras().toString());
LinearLayout nativeContainer = new LinearLayout(XandrNativeInAppMoPubDemoActivity.this);
nativeContainer.setOrientation(LinearLayout.VERTICAL);
LinearLayout iconAndTitle = new LinearLayout(XandrNativeInAppMoPubDemoActivity.this);
iconAndTitle.setOrientation(LinearLayout.HORIZONTAL);
ImageView icon = new ImageView(XandrNativeInAppMoPubDemoActivity.this);
icon.setLayoutParams(new LinearLayout.LayoutParams(160, 160));
Util.loadImage(icon, ad.getIconImageUrl());
iconAndTitle.addView(icon);
TextView title = new TextView(XandrNativeInAppMoPubDemoActivity.this);
title.setTextSize(20);
title.setText(ad.getTitle());
iconAndTitle.addView(title);
nativeContainer.addView(iconAndTitle);
ImageView image = new ImageView(XandrNativeInAppMoPubDemoActivity.this);
image.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Util.loadImage(image, ad.getMainImageUrl());
nativeContainer.addView(image);
TextView description = new TextView(XandrNativeInAppMoPubDemoActivity.this);
description.setTextSize(18);
description.setText(ad.getText());
nativeContainer.addView(description);
Button cta = new Button(XandrNativeInAppMoPubDemoActivity.this);
cta.setText(ad.getCallToAction());
cta.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(ad.getClickDestinationUrl()));
startActivity(browserIntent);
}
});
nativeContainer.addView(cta);
((FrameLayout) XandrNativeInAppMoPubDemoActivity.this.findViewById(R.id.adFrame)).addView(nativeContainer);
}
Aggregations