Java 类com.facebook.ads.MediaView 实例源码

项目:FBNativeAdAdapter    文件:FBNativeAdAdapter.java   
AdViewHolder(View view) {
    super(view);
    nativeAdContainer = (LinearLayout) view.findViewById(R.id.fb_native_ad_container);
    nativeAdIcon = (ImageView) view.findViewById(R.id.native_ad_icon);
    nativeAdTitle = (TextView) view.findViewById(R.id.native_ad_title);
    nativeAdMedia = (MediaView) view.findViewById(R.id.native_ad_media);
    nativeAdSocialContext = (TextView) view.findViewById(R.id.native_ad_social_context);
    nativeAdBody = (TextView) view.findViewById(R.id.native_ad_body);
    nativeAdCallToAction = (Button) view.findViewById(R.id.native_ad_call_to_action);
    adChoicesContainer = (LinearLayout) view.findViewById(R.id.ad_choices_container);
    loaded = false;
}
项目:MyAndroidTest    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MarkedImageView miv = (MarkedImageView) findViewById(R.id.mark_image);
    miv.showMark(true);

   MediaView ad = new MediaView(this);
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void requestNativeAd(Context context,
                            MediationNativeListener listener,
                            Bundle serverParameters,
                            NativeMediationAdRequest mediationAdRequest,
                            Bundle mediationExtras) {
    mNativeListener = listener;
    if (!isValidRequestParameters(context, serverParameters)) {
        mNativeListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST);
        return;
    }

    // Verify that the request is for both app install and content ads.
    if (!(mediationAdRequest.isAppInstallAdRequested()
            && mediationAdRequest.isContentAdRequested())) {
        Log.w(TAG, "Failed to request native ad. Both app install and content ad should be "
                + "requested");
        mNativeListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST);
        return;
    }

    String placementId = serverParameters.getString(PLACEMENT_PARAMETER);

    // Get the optional extras if set by the publisher.
    if (mediationExtras != null) {
        mIsAdChoicesIconExpandable = mediationExtras.getBoolean(
                FacebookExtrasBundleBuilder.KEY_EXPANDABLE_ICON, true);
    }

    mMediaView = new MediaView(context);

    mNativeAd = new NativeAd(context, placementId);
    mNativeAd.setAdListener(new NativeListener(mNativeAd, mediationAdRequest));
    buildAdRequest(mediationAdRequest);
    mNativeAd.loadAd();
}
项目:Sportmix    文件:PostItemAdapter.java   
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);
}