use of com.google.android.gms.ads.nativead.AdChoicesView in project mopub-android-mediation by mopub.
the class GooglePlayServicesAdRenderer method updateNativeAdview.
/**
* This method will render the given native ad view using the native ad and set the views to
* Google's native ad view.
*
* @param staticNativeAd a static native ad object containing the required assets to
* set to the native ad view.
* @param staticNativeViewHolder a static native view holder object containing the mapped
* views from the view binder.
* @param nativeAdView the Google native ad view in the view hierarchy.
*/
private void updateNativeAdview(GooglePlayServicesNativeAd staticNativeAd, GoogleStaticNativeViewHolder staticNativeViewHolder, NativeAdView nativeAdView) {
NativeRendererHelper.addTextView(staticNativeViewHolder.mTitleView, staticNativeAd.getTitle());
nativeAdView.setHeadlineView(staticNativeViewHolder.mTitleView);
NativeRendererHelper.addTextView(staticNativeViewHolder.mTextView, staticNativeAd.getText());
nativeAdView.setBodyView(staticNativeViewHolder.mTextView);
if (staticNativeViewHolder.mMediaView != null) {
MediaView mediaview = new MediaView(nativeAdView.getContext());
mediaview.setImageScaleType(ScaleType.CENTER_CROP);
staticNativeViewHolder.mMediaView.removeAllViews();
staticNativeViewHolder.mMediaView.addView(mediaview);
nativeAdView.setMediaView(mediaview);
}
NativeRendererHelper.addTextView(staticNativeViewHolder.mCallToActionView, staticNativeAd.getCallToAction());
nativeAdView.setCallToActionView(staticNativeViewHolder.mCallToActionView);
if (staticNativeAd.getIconImageUrl() != null) {
NativeImageHelper.loadImageView(staticNativeAd.getIconImageUrl(), staticNativeViewHolder.mIconImageView);
nativeAdView.setImageView(staticNativeViewHolder.mIconImageView);
}
if (staticNativeAd.getAdvertiser() != null) {
NativeRendererHelper.addTextView(staticNativeViewHolder.mAdvertiserTextView, staticNativeAd.getAdvertiser());
nativeAdView.setAdvertiserView(staticNativeViewHolder.mAdvertiserTextView);
}
// Add the AdChoices icon to the container if one is provided by the publisher.
if (staticNativeViewHolder.mAdChoicesIconContainer != null) {
AdChoicesView adChoicesView = new AdChoicesView(nativeAdView.getContext());
staticNativeViewHolder.mAdChoicesIconContainer.removeAllViews();
staticNativeViewHolder.mAdChoicesIconContainer.addView(adChoicesView);
nativeAdView.setAdChoicesView(adChoicesView);
}
// Set the privacy information icon to null as the Google Mobile Ads SDK automatically
// renders the AdChoices icon.
NativeRendererHelper.addPrivacyInformationIcon(staticNativeViewHolder.mPrivacyInformationIconImageView, null, null);
nativeAdView.setNativeAd(staticNativeAd.getNativeAd());
}
Aggregations