本文整理汇总了Java中com.google.android.gms.ads.formats.NativeAd.Image方法的典型用法代码示例。如果您正苦于以下问题:Java NativeAd.Image方法的具体用法?Java NativeAd.Image怎么用?Java NativeAd.Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.formats.NativeAd
的用法示例。
在下文中一共展示了NativeAd.Image方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SampleNativeContentAdMapper
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
public SampleNativeContentAdMapper(SampleNativeContentAd ad, NativeAdOptions adOptions) {
mSampleAd = ad;
mNativeAdOptions = adOptions;
setAdvertiser(mSampleAd.getAdvertiser());
setHeadline(mSampleAd.getHeadline());
setBody(mSampleAd.getBody());
setCallToAction(mSampleAd.getCallToAction());
setLogo(new SampleNativeMappedImage(ad.getLogo(), ad.getLogoUri(),
SampleCustomEvent.SAMPLE_SDK_IMAGE_SCALE));
List<NativeAd.Image> imagesList = new ArrayList<NativeAd.Image>();
imagesList.add(new SampleNativeMappedImage(ad.getImage(), ad.getImageUri(),
SampleCustomEvent.SAMPLE_SDK_IMAGE_SCALE));
setImages(imagesList);
Bundle extras = new Bundle();
extras.putString(SampleCustomEvent.DEGREE_OF_AWESOMENESS, ad.getDegreeOfAwesomeness());
this.setExtras(extras);
setOverrideClickHandling(false);
setOverrideImpressionRecording(false);
setAdChoicesContent(mSampleAd.getInformationIcon());
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:27,代码来源:SampleNativeContentAdMapper.java
示例2: populateView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates the asset {@link View}s contained it the {@link NativeContentAdView} with data
* from the {@link NativeContentAd} object. This method is invoked when an
* {@link ContentAdFetcher} has successfully loaded a {@link NativeContentAd}.
*
* @param contentAd the ad that is to be displayed
*/
public void populateView(NativeContentAd contentAd) {
((TextView) mAdView.getHeadlineView()).setText(contentAd.getHeadline());
((TextView) mAdView.getBodyView()).setText(contentAd.getBody());
((TextView) mAdView.getCallToActionView()).setText(contentAd.getCallToAction());
((TextView) mAdView.getAdvertiserView()).setText(contentAd.getAdvertiser());
List<NativeAd.Image> images = contentAd.getImages();
if (images != null && images.size() > 0) {
((ImageView) mAdView.getImageView())
.setImageDrawable(images.get(0).getDrawable());
}
NativeAd.Image logoImage = contentAd.getLogo();
if (logoImage != null) {
((ImageView) mAdView.getLogoView())
.setImageDrawable(logoImage.getDrawable());
}
// assign native ad object to the native view and make visible
mAdView.setNativeAd(contentAd);
mAdView.setVisibility(View.VISIBLE);
}
示例3: populateView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates the asset {@link View}s contained it the {@link NativeAppInstallAdView} with data
* from the {@link NativeAppInstallAd} object. This method is invoked when an
* {@link AppInstallAdFetcher} has successfully loaded a {@link NativeAppInstallAd}.
*
* @param appInstallAd the ad that is to be displayed
*/
public void populateView(NativeAppInstallAd appInstallAd) {
((TextView) mAdView.getHeadlineView()).setText(appInstallAd.getHeadline());
((TextView) mAdView.getBodyView()).setText(appInstallAd.getBody());
((TextView) mAdView.getPriceView()).setText(appInstallAd.getPrice());
((TextView) mAdView.getStoreView()).setText(appInstallAd.getStore());
((Button) mAdView.getCallToActionView()).setText(appInstallAd.getCallToAction());
((ImageView) mAdView.getIconView()).setImageDrawable(appInstallAd.getIcon().getDrawable());
((RatingBar) mAdView.getStarRatingView())
.setRating(appInstallAd.getStarRating().floatValue());
List<NativeAd.Image> images = appInstallAd.getImages();
if (images.size() > 0) {
((ImageView) mAdView.getImageView())
.setImageDrawable(images.get(0).getDrawable());
}
// assign native ad object to the native view and make visible
mAdView.setNativeAd(appInstallAd);
mAdView.setVisibility(View.VISIBLE);
}
示例4: populateContentAdView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates a {@link NativeContentAdView} object with data from a given
* {@link NativeContentAd}.
*
* @param nativeContentAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateContentAdView(NativeContentAd nativeContentAd,
NativeContentAdView adView) {
// Some assets are guaranteed to be in every NativeContentAd.
((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());
((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());
List<NativeAd.Image> images = nativeContentAd.getImages();
if (images.size() > 0) {
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
}
// Some aren't guaranteed, however, and should be checked.
NativeAd.Image logoImage = nativeContentAd.getLogo();
if (logoImage == null) {
adView.getLogoView().setVisibility(View.INVISIBLE);
} else {
((ImageView) adView.getLogoView()).setImageDrawable(logoImage.getDrawable());
adView.getLogoView().setVisibility(View.VISIBLE);
}
// Assign native ad object to the native view.
adView.setNativeAd(nativeContentAd);
}
示例5: SampleNativeContentAdMapper
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
public SampleNativeContentAdMapper(SampleNativeContentAd ad, NativeAdOptions adOptions) {
mSampleAd = ad;
mNativeAdOptions = adOptions;
setAdvertiser(mSampleAd.getAdvertiser());
setHeadline(mSampleAd.getHeadline());
setBody(mSampleAd.getBody());
setCallToAction(mSampleAd.getCallToAction());
setLogo(new SampleNativeMappedImage(ad.getLogo(), ad.getLogoUri(),
SampleAdapter.SAMPLE_SDK_IMAGE_SCALE));
List<NativeAd.Image> imagesList = new ArrayList<NativeAd.Image>();
imagesList.add(new SampleNativeMappedImage(ad.getImage(), ad.getImageUri(),
SampleAdapter.SAMPLE_SDK_IMAGE_SCALE));
setImages(imagesList);
Bundle extras = new Bundle();
extras.putString(SampleAdapter.DEGREE_OF_AWESOMENESS, ad.getDegreeOfAwesomeness());
this.setExtras(extras);
SampleMediaView mediaView = mSampleAd.getMediaView();
// Some ads from Sample SDK has video assets and some do not.
if(mediaView != null) {
setMediaView(mediaView);
setHasVideoContent(true);
} else {
setHasVideoContent(false);
}
setOverrideClickHandling(false);
setOverrideImpressionRecording(false);
setAdChoicesContent(mSampleAd.getInformationIcon());
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:37,代码来源:SampleNativeContentAdMapper.java
示例6: SampleNativeAppInstallAdMapper
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
public SampleNativeAppInstallAdMapper(SampleNativeAppInstallAd ad, NativeAdOptions adOptions) {
mSampleAd = ad;
mNativeAdOptions = adOptions;
setHeadline(mSampleAd.getHeadline());
setBody(mSampleAd.getBody());
setCallToAction(mSampleAd.getCallToAction());
setStarRating(mSampleAd.getStarRating());
setStore(mSampleAd.getStoreName());
setIcon(new SampleNativeMappedImage(ad.getAppIcon(), ad.getAppIconUri(),
SampleAdapter.SAMPLE_SDK_IMAGE_SCALE));
List<NativeAd.Image> imagesList = new ArrayList<NativeAd.Image>();
imagesList.add(new SampleNativeMappedImage(ad.getImage(), ad.getImageUri(),
SampleAdapter.SAMPLE_SDK_IMAGE_SCALE));
setImages(imagesList);
NumberFormat formatter = NumberFormat.getCurrencyInstance();
String priceString = formatter.format(mSampleAd.getPrice());
setPrice(priceString);
Bundle extras = new Bundle();
extras.putString(SampleAdapter.DEGREE_OF_AWESOMENESS, ad.getDegreeOfAwesomeness());
this.setExtras(extras);
SampleMediaView mediaView = mSampleAd.getMediaView();
// Some ads from Sample SDK has video assets and some do not.
if (mediaView != null) {
setMediaView(mediaView);
setHasVideoContent(true);
} else {
setHasVideoContent(false);
}
setOverrideClickHandling(false);
setOverrideImpressionRecording(false);
setAdChoicesContent(mSampleAd.getInformationIcon());
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:40,代码来源:SampleNativeAppInstallAdMapper.java
示例7: SampleNativeAppInstallAdMapper
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
public SampleNativeAppInstallAdMapper(SampleNativeAppInstallAd ad, NativeAdOptions adOptions) {
mSampleAd = ad;
mNativeAdOptions = adOptions;
setHeadline(mSampleAd.getHeadline());
setBody(mSampleAd.getBody());
setCallToAction(mSampleAd.getCallToAction());
setStarRating(mSampleAd.getStarRating());
setStore(mSampleAd.getStoreName());
setIcon(new SampleNativeMappedImage(ad.getAppIcon(), ad.getAppIconUri(),
SampleCustomEvent.SAMPLE_SDK_IMAGE_SCALE));
List<NativeAd.Image> imagesList = new ArrayList<NativeAd.Image>();
imagesList.add(new SampleNativeMappedImage(ad.getImage(), ad.getImageUri(),
SampleCustomEvent.SAMPLE_SDK_IMAGE_SCALE));
setImages(imagesList);
NumberFormat formatter = NumberFormat.getCurrencyInstance();
String priceString = formatter.format(mSampleAd.getPrice());
setPrice(priceString);
Bundle extras = new Bundle();
extras.putString(SampleCustomEvent.DEGREE_OF_AWESOMENESS, ad.getDegreeOfAwesomeness());
this.setExtras(extras);
setOverrideClickHandling(false);
setOverrideImpressionRecording(false);
setAdChoicesContent(mSampleAd.getInformationIcon());
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:30,代码来源:SampleNativeAppInstallAdMapper.java
示例8: populateContentAdView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates a {@link NativeContentAdView} object with data from a given
* {@link NativeContentAd}.
*
* @param nativeContentAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateContentAdView(NativeContentAd nativeContentAd,
NativeContentAdView adView) {
mVideoStatus.setText("Video status: Ad does not contain a video asset.");
mRefresh.setEnabled(true);
adView.setHeadlineView(adView.findViewById(R.id.contentad_headline));
adView.setImageView(adView.findViewById(R.id.contentad_image));
adView.setBodyView(adView.findViewById(R.id.contentad_body));
adView.setCallToActionView(adView.findViewById(R.id.contentad_call_to_action));
adView.setLogoView(adView.findViewById(R.id.contentad_logo));
adView.setAdvertiserView(adView.findViewById(R.id.contentad_advertiser));
// Some assets are guaranteed to be in every NativeContentAd.
((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());
((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());
List<NativeAd.Image> images = nativeContentAd.getImages();
if (images.size() > 0) {
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
}
// Some aren't guaranteed, however, and should be checked.
NativeAd.Image logoImage = nativeContentAd.getLogo();
if (logoImage == null) {
adView.getLogoView().setVisibility(View.INVISIBLE);
} else {
((ImageView) adView.getLogoView()).setImageDrawable(logoImage.getDrawable());
adView.getLogoView().setVisibility(View.VISIBLE);
}
// Assign native ad object to the native view.
adView.setNativeAd(nativeContentAd);
}
示例9: populateAppInstallAdView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates a {@link NativeAppInstallAdView} object with data from a given
* {@link NativeAppInstallAd}.
*
* @param nativeAppInstallAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateAppInstallAdView(NativeAppInstallAd nativeAppInstallAd,
NativeAppInstallAdView adView) {
VideoController videoController = nativeAppInstallAd.getVideoController();
// Assign native ad object to the native view.
adView.setNativeAd(nativeAppInstallAd);
adView.setHeadlineView(adView.findViewById(R.id.appinstall_headline));
adView.setBodyView(adView.findViewById(R.id.appinstall_body));
adView.setCallToActionView(adView.findViewById(R.id.appinstall_call_to_action));
adView.setIconView(adView.findViewById(R.id.appinstall_app_icon));
adView.setPriceView(adView.findViewById(R.id.appinstall_price));
adView.setStarRatingView(adView.findViewById(R.id.appinstall_stars));
adView.setStoreView(adView.findViewById(R.id.appinstall_store));
// Some assets are guaranteed to be in every NativeAppInstallAd.
((TextView) adView.getHeadlineView()).setText(nativeAppInstallAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeAppInstallAd.getBody());
((Button) adView.getCallToActionView()).setText(nativeAppInstallAd.getCallToAction());
((ImageView) adView.getIconView()).setImageDrawable(nativeAppInstallAd.getIcon()
.getDrawable());
MediaView sampleMediaView = adView.findViewById(R.id.appinstall_media);
ImageView imageView = adView.findViewById(R.id.appinstall_image);
if (videoController.hasVideoContent()) {
imageView.setVisibility(View.GONE);
adView.setMediaView(sampleMediaView);
} else {
sampleMediaView.setVisibility(View.GONE);
adView.setImageView(imageView);
List<NativeAd.Image> images = nativeAppInstallAd.getImages();
if (images.size() > 0) {
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
}
}
// Some aren't guaranteed, however, and should be checked.
if (nativeAppInstallAd.getPrice() == null) {
adView.getPriceView().setVisibility(View.INVISIBLE);
} else {
adView.getPriceView().setVisibility(View.VISIBLE);
((TextView) adView.getPriceView()).setText(nativeAppInstallAd.getPrice());
}
if (nativeAppInstallAd.getStore() == null) {
adView.getStoreView().setVisibility(View.INVISIBLE);
} else {
adView.getStoreView().setVisibility(View.VISIBLE);
((TextView) adView.getStoreView()).setText(nativeAppInstallAd.getStore());
}
if (nativeAppInstallAd.getStarRating() == null) {
adView.getStarRatingView().setVisibility(View.INVISIBLE);
} else {
((RatingBar) adView.getStarRatingView())
.setRating(nativeAppInstallAd.getStarRating().floatValue());
adView.getStarRatingView().setVisibility(View.VISIBLE);
}
// Handle the fact that this could be a Sample SDK native ad, which includes a
// "degree of awesomeness" field.
Bundle extras = nativeAppInstallAd.getExtras();
if (extras.containsKey(SampleCustomEvent.DEGREE_OF_AWESOMENESS)) {
TextView degree = (TextView) adView.findViewById(R.id.appinstall_degreeofawesomeness);
degree.setVisibility(View.VISIBLE);
degree.setText(extras.getString(SampleCustomEvent.DEGREE_OF_AWESOMENESS));
}
}
示例10: populateContentAdView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates a {@link NativeContentAdView} object with data from a given
* {@link NativeContentAd}.
*
* @param nativeContentAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateContentAdView(NativeContentAd nativeContentAd,
NativeContentAdView adView) {
// Assign native ad object to the native view.
adView.setNativeAd(nativeContentAd);
adView.setHeadlineView(adView.findViewById(R.id.contentad_headline));
adView.setImageView(adView.findViewById(R.id.contentad_image));
adView.setBodyView(adView.findViewById(R.id.contentad_body));
adView.setCallToActionView(adView.findViewById(R.id.contentad_call_to_action));
adView.setLogoView(adView.findViewById(R.id.contentad_logo));
adView.setAdvertiserView(adView.findViewById(R.id.contentad_advertiser));
// Some assets are guaranteed to be in every NativeContentAd.
((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());
((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());
List<NativeAd.Image> images = nativeContentAd.getImages();
if (images.size() > 0) {
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
}
// Some aren't guaranteed, however, and should be checked.
NativeAd.Image logoImage = nativeContentAd.getLogo();
if (logoImage == null) {
adView.getLogoView().setVisibility(View.INVISIBLE);
} else {
((ImageView) adView.getLogoView())
.setImageDrawable(logoImage.getDrawable());
adView.getLogoView().setVisibility(View.VISIBLE);
}
// Handle the fact that this could be a Sample SDK native ad, which includes a
// "degree of awesomeness" field.
Bundle extras = nativeContentAd.getExtras();
if (extras.containsKey(SampleCustomEvent.DEGREE_OF_AWESOMENESS)) {
TextView degree = (TextView) adView.findViewById(R.id.appinstall_degreeofawesomeness);
degree.setVisibility(View.VISIBLE);
degree.setText(extras.getString(SampleCustomEvent.DEGREE_OF_AWESOMENESS));
}
}
示例11: populateContentAdView
import com.google.android.gms.ads.formats.NativeAd; //导入方法依赖的package包/类
/**
* Populates a {@link NativeContentAdView} object with data from a given
* {@link NativeContentAd}.
*
* @param nativeContentAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateContentAdView(NativeContentAd nativeContentAd,
NativeContentAdView adView) {
adView.setHeadlineView(adView.findViewById(R.id.contentad_headline));
adView.setBodyView(adView.findViewById(R.id.contentad_body));
adView.setCallToActionView(adView.findViewById(R.id.contentad_call_to_action));
adView.setLogoView(adView.findViewById(R.id.contentad_logo));
adView.setAdvertiserView(adView.findViewById(R.id.contentad_advertiser));
// Some assets are guaranteed to be in every NativeContentAd.
((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());
((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());
// Get the video controller for the ad. One will always be provided, even if the ad doesn't
// have a video asset.
VideoController vc = nativeContentAd.getVideoController();
MediaView mediaView = adView.findViewById(R.id.contentad_media);
ImageView mainImageView = adView.findViewById(R.id.contentad_image);
// Apps can check the VideoController's hasVideoContent property to determine if the
// NativeContentAd has a video asset.
if (vc.hasVideoContent()) {
mainImageView.setVisibility(View.GONE);
adView.setMediaView(mediaView);
mVideoStatus.setText(String.format(Locale.getDefault(),
"Video status: Ad contains a %.2f:1 video asset.",
vc.getAspectRatio()));
// Create a new VideoLifecycleCallbacks object and pass it to the VideoController. The
// VideoController will call methods on this object when events occur in the video
// lifecycle.
vc.setVideoLifecycleCallbacks(new VideoController.VideoLifecycleCallbacks() {
public void onVideoEnd() {
// Publishers should allow native ads to complete video playback before
// refreshing or replacing them with another ad in the same UI location.
mRefresh.setEnabled(true);
mVideoStatus.setText("Video status: Video playback has ended.");
super.onVideoEnd();
}
});
} else {
mediaView.setVisibility(View.GONE);
adView.setImageView(mainImageView);
// At least one image is guaranteed.
List<NativeAd.Image> images = nativeContentAd.getImages();
mainImageView.setImageDrawable(images.get(0).getDrawable());
mRefresh.setEnabled(true);
mVideoStatus.setText("Video status: Ad does not contain a video asset.");
}
// These assets aren't guaranteed to be in every NativeContentAd, so it's important to
// check before trying to display them.
NativeAd.Image logoImage = nativeContentAd.getLogo();
if (logoImage == null) {
adView.getLogoView().setVisibility(View.INVISIBLE);
} else {
((ImageView) adView.getLogoView()).setImageDrawable(logoImage.getDrawable());
adView.getLogoView().setVisibility(View.VISIBLE);
}
// Assign native ad object to the native view.
adView.setNativeAd(nativeContentAd);
}