当前位置: 首页>>代码示例>>Java>>正文


Java NativeAd.getAdCoverImage方法代码示例

本文整理汇总了Java中com.facebook.ads.NativeAd.getAdCoverImage方法的典型用法代码示例。如果您正苦于以下问题:Java NativeAd.getAdCoverImage方法的具体用法?Java NativeAd.getAdCoverImage怎么用?Java NativeAd.getAdCoverImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.ads.NativeAd的用法示例。


在下文中一共展示了NativeAd.getAdCoverImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setNativeAd

import com.facebook.ads.NativeAd; //导入方法依赖的package包/类
/**
 * Called by the view manager when adsManager prop is set. Sends serialised
 * version of a native ad back to Javascript.
 *
 * Automatically registers current view for interactions on an ad so that
 * it becomes clickable.
 *
 * @param nativeAd
 */
public void setNativeAd(NativeAd nativeAd) {
    mNativeAd = nativeAd;

    if (nativeAd == null) {
        mEventEmitter.receiveEvent(getId(), "onAdLoaded", null);
        return;
    }

    NativeAd.Image coverImage = nativeAd.getAdCoverImage();
    NativeAd.Image iconImage = nativeAd.getAdIcon();

    WritableMap event = Arguments.createMap();
    event.putString("title", nativeAd.getAdTitle());
    event.putString("subtitle", nativeAd.getAdSubtitle());
    event.putString("description", nativeAd.getAdBody());
    event.putString("callToActionText", nativeAd.getAdCallToAction());

    // Check as they might be null because of memory issues on low-end devices
    if (coverImage != null) {
        event.putString("coverImage", coverImage.getUrl());
    }

    if (iconImage != null) {
        event.putString("icon", iconImage.getUrl());
    }

    mEventEmitter.receiveEvent(getId(), "onAdLoaded", event);

    mNativeAd.registerViewForInteraction(this);
}
 
开发者ID:callstack,项目名称:react-native-fbads,代码行数:40,代码来源:NativeAdView.java

示例2: inflateAd

import com.facebook.ads.NativeAd; //导入方法依赖的package包/类
private void inflateAd(NativeAd nativeAd, View adView) {
    // Create native UI using the ad metadata.
    ImageView nativeAdIcon = (ImageView) adView.findViewById(R.id.native_ad_icon);
    TextView nativeAdTitle = (TextView) adView.findViewById(R.id.native_ad_title);
    TextView nativeAdBody = (TextView) adView.findViewById(R.id.native_ad_body);
    MediaView nativeAdMedia = (MediaView) adView.findViewById(R.id.native_ad_media);
    nativeAdMedia.setAutoplay(AdSettings.isVideoAutoplay());
    TextView nativeAdSocialContext =
            (TextView) adView.findViewById(R.id.native_ad_social_context);
    Button nativeAdCallToAction = (Button) adView.findViewById(R.id.native_ad_call_to_action);

    // Setting the Text
    nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
    nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
    nativeAdCallToAction.setVisibility(View.VISIBLE);
    nativeAdTitle.setText(nativeAd.getAdTitle());
    nativeAdBody.setText(nativeAd.getAdBody());

    // Downloading and setting the ad icon.
    NativeAd.Image adIcon = nativeAd.getAdIcon();
    NativeAd.downloadAndDisplayImage(adIcon, nativeAdIcon);

    // Downloading and setting the cover image.
    NativeAd.Image adCoverImage = nativeAd.getAdCoverImage();
    int bannerWidth = adCoverImage.getWidth();
    int bannerHeight = adCoverImage.getHeight();
    DisplayMetrics metrics = myContext.getResources().getDisplayMetrics();
    int mediaWidth = adView.getWidth() > 0 ? adView.getWidth() : metrics.widthPixels;
    nativeAdMedia.setLayoutParams(new LinearLayout.LayoutParams(
            mediaWidth,
            Math.min(
                    (int) (((double) mediaWidth / (double) bannerWidth) * bannerHeight),
                    metrics.heightPixels / 7))); // eskiden 3
    nativeAdMedia.setNativeAd(nativeAd);

    // Wire up the View with the native ad, the whole nativeAdContainer will be clickable.
    nativeAd.registerViewForInteraction(adView);
}
 
开发者ID:aknkaplanoglu,项目名称:Sportmix,代码行数:39,代码来源:PostItemAdapter.java

示例3: inflateAd

import com.facebook.ads.NativeAd; //导入方法依赖的package包/类
public void inflateAd(NativeAd nativeAd, View adView, Context context) {
    // Create native UI using the ad metadata.

    ImageView nativeAdIcon = (ImageView) adView.findViewById(R.id.nativeAdIcon);
    TextView nativeAdTitle = (TextView) adView.findViewById(R.id.nativeAdTitle);
    TextView nativeAdTitleRating = (TextView) adView.findViewById(R.id.nativeAdTitleRating);
    TextView nativeAdBody = (TextView) adView.findViewById(R.id.nativeAdBody);

    ImageView nativeAdImage = (ImageView) adView.findViewById(R.id.nativeAdImage);
    TextView nativeAdSocialContext = (TextView) adView.findViewById(R.id.nativeAdSocialContext);
    FaceBookAdButton nativeAdCallToAction = (FaceBookAdButton) adView.findViewById(R.id.nativeAdCallToAction);
    RatingBar nativeAdStarRating = (RatingBar) adView.findViewById(R.id.nativeAdStarRating);

    // Setting the Text
    nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
    nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
    nativeAdTitle.setText(nativeAd.getAdTitle());
    nativeAdTitleRating.setText(nativeAd.getAdTitle());
    nativeAdBody.setText(nativeAd.getAdBody());

    // Downloading and setting the ad icon.
    NativeAd.Image adIcon = nativeAd.getAdIcon();
    NativeAd.downloadAndDisplayImage(adIcon, nativeAdIcon);

    // Downloading and setting the cover image.
    NativeAd.Image adCoverImage = nativeAd.getAdCoverImage();
    int bannerWidth = adCoverImage.getWidth();
    int bannerHeight = adCoverImage.getHeight();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    int screenWidth = metrics.widthPixels;
    int screenHeight = metrics.heightPixels;
    nativeAdImage.setLayoutParams(new LinearLayout.LayoutParams(
            screenWidth,
            Math.min((int) (((double) screenWidth / (double) bannerWidth) * bannerHeight), screenHeight / 3)
    ));
    NativeAd.downloadAndDisplayImage(adCoverImage, nativeAdImage);

    NativeAd.Rating rating = nativeAd.getAdStarRating();
    if (rating != null) {
        nativeAdStarRating.setVisibility(View.VISIBLE);
        nativeAdStarRating.setNumStars((int) rating.getScale());
        nativeAdStarRating.setRating((float) rating.getValue());
    } else {
        nativeAdStarRating.setVisibility(View.GONE);
    }

    // Wire up the View with the native ad, the whole nativeAdContainer will be clickable
    //nativeAd.registerViewForInteraction(adView);


    // Or you can replace the above call with the following function to specify the clickable areas.
    nativeAd.registerViewForInteraction(adView, Arrays.asList(nativeAdCallToAction));

}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:58,代码来源:TimelineAdapter.java

示例4: inflateAd

import com.facebook.ads.NativeAd; //导入方法依赖的package包/类
public static void inflateAd(NativeAd nativeAd, View adView, Context context) {
    // Create native UI using the ad metadata.

    ImageView nativeAdIcon = (ImageView) adView.findViewById(R.id.nativeAdIcon);
    TextView nativeAdTitle = (TextView) adView.findViewById(R.id.nativeAdTitle);
    TextView nativeAdBody = (TextView) adView.findViewById(R.id.nativeAdBody);
    ImageView nativeAdImage = (ImageView) adView.findViewById(R.id.nativeAdImage);
    TextView nativeAdSocialContext = (TextView) adView.findViewById(R.id.nativeAdSocialContext);
    Button nativeAdCallToAction = (Button) adView.findViewById(R.id.nativeAdCallToAction);
    RatingBar nativeAdStarRating = (RatingBar) adView.findViewById(R.id.nativeAdStarRating);

    // Setting the Text
    nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
    nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
    nativeAdCallToAction.setVisibility(View.VISIBLE);
    nativeAdTitle.setText(nativeAd.getAdTitle());
    nativeAdBody.setText(nativeAd.getAdBody());

    // Downloading and setting the ad icon.
    NativeAd.Image adIcon = nativeAd.getAdIcon();
    NativeAd.downloadAndDisplayImage(adIcon, nativeAdIcon);

    // Downloading and setting the cover image.
    NativeAd.Image adCoverImage = nativeAd.getAdCoverImage();
    int bannerWidth = adCoverImage.getWidth();
    int bannerHeight = adCoverImage.getHeight();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    int screenWidth = metrics.widthPixels;
    int screenHeight = metrics.heightPixels;
    nativeAdImage.setLayoutParams(new LinearLayout.LayoutParams(
            screenWidth,
            Math.min((int) (((double) screenWidth / (double) bannerWidth) * bannerHeight), screenHeight / 3)
            ));
    NativeAd.downloadAndDisplayImage(adCoverImage, nativeAdImage);

    NativeAd.Rating rating = nativeAd.getAdStarRating();
    if (rating != null) {
        nativeAdStarRating.setVisibility(View.VISIBLE);
        nativeAdStarRating.setNumStars((int) rating.getScale());
        nativeAdStarRating.setRating((float) rating.getValue());
    } else {
        nativeAdStarRating.setVisibility(View.GONE);
    }

    // Wire up the View with the native ad, the whole nativeAdContainer will be clickable
    nativeAd.registerViewForInteraction(adView);

    // Or you can replace the above call with the following function to specify the clickable areas.
    // nativeAd.registerViewForInteraction(nativeAdContainer, Arrays.asList(nativeAdCallToAction, nativeAdImage));
}
 
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:54,代码来源:NativeAdSampleActivity.java

示例5: containsRequiredFieldsForNativeAppInstallAd

import com.facebook.ads.NativeAd; //导入方法依赖的package包/类
/**
 * This method will check whether or not the given Facebook native ad contains all the
 * necessary fields for it to be mapped to Google Mobile Ads' native app install ad.
 *
 * @param nativeAd Facebook native ad.
 * @return {@code true} if the given ad contains all the necessary fields, {@link false}
 * otherwise.
 */
private boolean containsRequiredFieldsForNativeAppInstallAd(NativeAd nativeAd) {
    return ((nativeAd.getAdTitle() != null) && (nativeAd.getAdCoverImage() != null)
            && (nativeAd.getAdBody() != null) && (nativeAd.getAdIcon() != null)
            && (nativeAd.getAdCallToAction() != null));
}
 
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:14,代码来源:FacebookAdapter.java


注:本文中的com.facebook.ads.NativeAd.getAdCoverImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。