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

项目:mopub-nativead-adapters    文件:FacebookNativeAd.java   
@Override
public void onError(final Ad ad, final AdError adError) {
    if (adError == null) {
        this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
    } else {
        switch (adError.getErrorCode()) {
            case AdError.NO_FILL_ERROR_CODE:
                this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.NETWORK_NO_FILL);
                break;

            case AdError.NETWORK_ERROR_CODE:
                this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.CONNECTION_ERROR);
                break;

            case AdError.SERVER_ERROR_CODE:
                this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.SERVER_ERROR_RESPONSE_CODE);
                break;

            default:
                this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.UNEXPECTED_RESPONSE_CODE);
                break;
        }
    }
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {

    String errorString = DEFAULT_ERROR;
    if (adError != null) {
        errorString = adError.getErrorCode() + " - " + adError.getErrorMessage();
    }
    if (adError == null) {
        invokeLoadFail(new Exception(errorString));
    } else {

        switch (adError.getErrorCode()) {
            case AdError.NO_FILL_ERROR_CODE:
            case AdError.LOAD_TOO_FREQUENTLY_ERROR_CODE:
            case Facebook.ERROR_NO_FILL_1203:
                invokeLoadFail(new Exception("Facebook error: no-fill"));
                break;
            default:
                invokeLoadFail(new Exception(errorString));
                break;
        }
    }
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {

    String errorString = DEFAULT_ERROR;
    if (adError != null) {
        errorString = adError.getErrorCode() + " - " + adError.getErrorMessage();
    }
    if (adError == null) {
        invokeLoadFail(new Exception(errorString));
    } else {

        switch (adError.getErrorCode()) {
            case AdError.NO_FILL_ERROR_CODE:
            case AdError.LOAD_TOO_FREQUENTLY_ERROR_CODE:
            case Facebook.ERROR_NO_FILL_1203:
                invokeLoadFinish(null);
                break;
            default:
                invokeLoadFail(new Exception(errorString));
                break;
        }
    }
}
项目:react-native-fbads    文件:BannerView.java   
@Override
public void onAdLoaded(Ad ad) {
  this.removeAllViews();

  Resources r = mContext.getResources();
  DisplayMetrics dm = r.getDisplayMetrics();
  int pxW = mSize.getWidth() > 0 ?
    dp2px(mSize.getWidth(), dm)
    : r.getDisplayMetrics().widthPixels;
  int pxH = dp2px(mSize.getHeight(), dm);

  myAdView.measure(pxW, pxH);
  myAdView.layout(0, 0, pxW, pxH);

  addView(myAdView);
}
项目:adsnative-sdk-android    文件:FacebookAdNetwork.java   
@Override
public void onError(final Ad ad, final AdError adError) {
    ANLog.e("FacebookAdNetwork#onError");
    if (adError == null) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.UNSPECIFIED);
        mCustomEventListener.onNativeAdFailed(ErrorCode.UNSPECIFIED);
    } else if (adError.getErrorCode() == AdError.NO_FILL.getErrorCode()) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.NETWORK_NO_FILL);
        mCustomEventListener.onNativeAdFailed(ErrorCode.NETWORK_NO_FILL);
    } else if (adError.getErrorCode() == AdError.INTERNAL_ERROR.getErrorCode()) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.NETWORK_INVALID_STATE + " : " +
                AdError.INTERNAL_ERROR.getErrorCode());
        mCustomEventListener.onNativeAdFailed(ErrorCode.NETWORK_INVALID_STATE);
    } else {
        ANLog.e("FacebookAdNetwork: " + adError.getErrorMessage());
        mCustomEventListener.onNativeAdFailed(ErrorCode.UNSPECIFIED);
    }
}
项目:adsnative-sdk-android    文件:FacebookAdNetwork.java   
@Override
public void onError(final Ad ad, final AdError adError) {
    ANLog.e("FacebookAdNetwork#onError");
    if (adError == null) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.UNSPECIFIED);
        mCustomEventListener.onNativeAdFailed(ErrorCode.UNSPECIFIED);
    } else if (adError.getErrorCode() == AdError.NO_FILL.getErrorCode()) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.NETWORK_NO_FILL);
        mCustomEventListener.onNativeAdFailed(ErrorCode.NETWORK_NO_FILL);
    } else if (adError.getErrorCode() == AdError.INTERNAL_ERROR.getErrorCode()) {
        ANLog.e("FacebookAdNetwork: " + ErrorCode.NETWORK_INVALID_STATE + " : " +
                AdError.INTERNAL_ERROR.getErrorCode());
        mCustomEventListener.onNativeAdFailed(ErrorCode.NETWORK_INVALID_STATE);
    } else {
        ANLog.e("FacebookAdNetwork: " + adError.getErrorMessage());
        mCustomEventListener.onNativeAdFailed(ErrorCode.UNSPECIFIED);
    }
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onAdLoaded(Ad ad) {
    if (ad != mNativeAd) {
        Log.w(TAG, "Ad loaded is not a native ad.");
        FacebookAdapter.this.mNativeListener.onAdFailedToLoad(
                FacebookAdapter.this, AdRequest.ERROR_CODE_INTERNAL_ERROR);
        return;
    }

    NativeAdOptions options = mMediationAdRequest.getNativeAdOptions();
    // We always convert the ad into an app install ad.
    final AppInstallMapper mapper = new AppInstallMapper(mNativeAd, options);
    mapper.mapNativeAd(new NativeAdMapperListener() {
        @Override
        public void onMappingSuccess() {
            mNativeListener.onAdLoaded(FacebookAdapter.this, mapper);
        }

        @Override
        public void onMappingFailed() {
            mNativeListener.onAdFailedToLoad(FacebookAdapter.this,
                    AdRequest.ERROR_CODE_NO_FILL);
        }
    });
}
项目:mobile-sdk-android    文件:FacebookListener.java   
@Override
public void onError(Ad ad, AdError adError) {
    Clog.d(Clog.mediationLogTag, className + " | Facebook - onError called for AdView with error message " + adError.getErrorMessage());
    ResultCode code;

    if (adError.getErrorCode() == AdError.NO_FILL.getErrorCode()) {
        code = ResultCode.UNABLE_TO_FILL;
    } else if (adError.getErrorCode() == AdError.LOAD_TOO_FREQUENTLY.getErrorCode()) {
        code = ResultCode.INVALID_REQUEST;
    } else if (adError.getErrorCode() == AdError.INTERNAL_ERROR.getErrorCode()) {
        code = ResultCode.INTERNAL_ERROR;
    } else if (adError.getErrorCode() == AdError.MISSING_PROPERTIES.getErrorCode()) {
        code = ResultCode.INVALID_REQUEST;
    } else {
        code = ResultCode.INTERNAL_ERROR;
    }

    if (mediatedAdViewController != null) {
        mediatedAdViewController.onAdFailed(code);
    }
}
项目:kognitivo    文件:InterstitialFragment.java   
@Override
public void onInterstitialDismissed(Ad ad) {
    Toast.makeText(this.getActivity(), "Interstitial Dismissed", Toast.LENGTH_SHORT).show();

    // Cleanup.
    interstitialAd.destroy();
    interstitialAd = null;
}
项目:sekai    文件:InterstitialFragment.java   
@Override
public void onInterstitialDismissed(Ad ad) {
    Toast.makeText(this.getActivity(), "Interstitial Dismissed", Toast.LENGTH_SHORT).show();

    // Cleanup.
    interstitialAd.destroy();
    interstitialAd = null;
}
项目:aptoide-client    文件:FragmentSocialTimeline.java   
@Override
public void onAdLoaded(Ad ad) {
    Logger.d("FragmentSocialTimeline","onAdLoaded , ad: "+ad.toString());
    if(getActivity() != null){
        adapter.addNativeAd((NativeAd) ad,getActivity(),apks);
    }

}
项目:mopub-nativead-adapters    文件:FacebookNativeAd.java   
@Override
public void onAdLoaded(final Ad ad) {
    // This identity check is from Facebook's Native API sample code:
    // https://developers.facebook.com/docs/audience-network/android/native-api
    if (!this.nativeAd.equals(ad) || !this.nativeAd.isAdLoaded()) {
        this.getCustomEventNativeListener().onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_STATE);
        return;
    }

    this.setTitle(this.nativeAd.getAdTitle());
    this.setText(this.nativeAd.getAdBody());

    final NativeAd.Image coverImage = this.nativeAd.getAdCoverImage();
    if (coverImage != null) this.setMainImageUrl(coverImage.getUrl());

    final NativeAd.Image icon = this.nativeAd.getAdIcon();
    if (icon != null) this.setIconImageUrl(icon.getUrl());

    this.setCallToAction(this.nativeAd.getAdCallToAction());
    this.setStarRating(FacebookNativeAd.getStarRatingValue(this.nativeAd.getAdStarRating()));

    this.addExtra(FacebookNativeAd.SOCIAL_CONTEXT_FOR_AD, this.nativeAd.getAdSocialContext());

    final NativeAd.Image adChoicesIconImage = this.nativeAd.getAdChoicesIcon();
    if (adChoicesIconImage != null) {
        this.setPrivacyInformationIconImageUrl(adChoicesIconImage.getUrl());
        this.setPrivacyInformationIconClickThroughUrl(this.nativeAd.getAdChoicesLinkUrl());
    }

    this.preCacheImages(this.getImageUrls());

    this.setImpressionMinTimeViewed(BaseStaticNativeAd.IMPRESSION_MIN_TIME);
}
项目:pubnative-android-sdk    文件:FacebookNetworkInterstitialAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorString = DEFAULT_ERROR;
    if (adError != null) {
        errorString = adError.getErrorCode() + " - " + adError.getErrorMessage();
    }
    invokeLoadFail(new Exception(errorString));
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorString = DEFAULT_ERROR;
    if (adError != null) {
        errorString = adError.getErrorCode() + " - " + adError.getErrorMessage();
    }
    invokeLoadFail(new Exception(errorString));
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onAdLoaded(Ad ad) {

    mWrapper = new FacebookNativeAdModel(mContext, mNativeAd);
    mAdView = new PNLargeLayoutRequestView(mContext);
    mAdView.loadWithAd(mContext, mWrapper);
    invokeLoadSuccess();
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorString = DEFAULT_ERROR;
    if (adError != null) {
        errorString = adError.getErrorCode() + " - " + adError.getErrorMessage();
    }
    invokeLoadFail(new Exception(errorString));
}
项目:pubnative-android-sdk    文件:FacebookNetworkAdapter.java   
@Override
public void onAdLoaded(Ad ad) {
    if (ad == mNativeAd) {
        FacebookNativeAdModel wrapModel = new FacebookNativeAdModel(mContext, (NativeAd) ad);
        wrapModel.setInsightModel(mInsight);
        invokeLoadFinish(wrapModel);
    }
}
项目:react-native-fbads    文件:BannerView.java   
@Override
public void onError(Ad ad, AdError adError) {
  WritableMap event = Arguments.createMap();

  event.putInt("errorCode", adError.getErrorCode());
  event.putString("errorMessage", adError.getErrorMessage());
  mEventEmitter.receiveEvent(getId(), "onAdError", event);

  myAdView = null;
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onAdClicked(Ad ad) {
    FacebookAdapter.this.mBannerListener.onAdClicked(FacebookAdapter.this);
    FacebookAdapter.this.mBannerListener.onAdOpened(FacebookAdapter.this);
    // The test Facebook ads leave the application when the ad is clicked. Assuming all
    // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
    FacebookAdapter.this.mBannerListener.onAdLeftApplication(FacebookAdapter.this);
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorMessage = adError.getErrorMessage();
    if (!TextUtils.isEmpty(errorMessage)) {
        Log.w(TAG, errorMessage);
    }
    FacebookAdapter.this.mBannerListener.onAdFailedToLoad(
            FacebookAdapter.this, convertErrorCode(adError));
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onAdClicked(Ad ad) {
    FacebookAdapter.this.mInterstitialListener.onAdClicked(FacebookAdapter.this);
    // The test Facebook ads leave the application when the ad is clicked. Assuming all
    // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
    FacebookAdapter.this.mInterstitialListener.onAdLeftApplication(FacebookAdapter.this);
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorMessage = adError.getErrorMessage();
    if (!TextUtils.isEmpty(errorMessage)) {
        Log.w(TAG, errorMessage);
    }
    FacebookAdapter.this.mInterstitialListener.onAdFailedToLoad(
            FacebookAdapter.this, convertErrorCode(adError));
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorMessage = adError.getErrorMessage();
    if (!TextUtils.isEmpty(errorMessage)) {
        Log.w(TAG, errorMessage);
    }

    mRewardedListener.onAdFailedToLoad(FacebookAdapter.this, convertErrorCode(adError));
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onAdClicked(Ad ad) {
    FacebookAdapter.this.mNativeListener.onAdClicked(FacebookAdapter.this);
    FacebookAdapter.this.mNativeListener.onAdOpened(FacebookAdapter.this);
    // The test Facebook ads leave the application when the ad is clicked. Assuming all
    // the ads do the same, sending onAdLeftApplication callback when the ad is clicked.
    FacebookAdapter.this.mNativeListener.onAdLeftApplication(FacebookAdapter.this);
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onLoggingImpression(Ad ad) {
    if (mIsImpressionRecorded) {
        Log.d(TAG, "Received onLoggingImpression callback for a native whose impression"
                + " is already recorded. Ignoring the duplicate callback.");
        return;
    }
    FacebookAdapter.this.mNativeListener.onAdImpression(FacebookAdapter.this);
    mIsImpressionRecorded = true;
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
@Override
public void onError(Ad ad, AdError adError) {
    String errorMessage = adError.getErrorMessage();
    if (!TextUtils.isEmpty(errorMessage)) {
        Log.w(TAG, errorMessage);
    }
    FacebookAdapter.this.mNativeListener.onAdFailedToLoad(
            FacebookAdapter.this, convertErrorCode(adError));
}
项目:HereAStory-Android    文件:NativeAdSampleActivity.java   
@Override
public void onAdLoaded(Ad ad) {
    if (nativeAd == null || nativeAd != ad) {
        // Race condition, load() called again before last ad was displayed
        return;
    }

    // Unregister last ad
    nativeAd.unregisterView();

    nativeAdStatus.setText("");

    inflateAd(nativeAd, adView, this);
}
项目:kognitivo    文件:RectangleFragment.java   
@Override
public void onError(Ad ad, AdError error) {
    if (ad == adViewRectangle) {
        setLabel("Ad failed to load: " + error.getErrorMessage());
    }
}
项目:kognitivo    文件:RectangleFragment.java   
@Override
public void onAdLoaded(Ad ad) {
    if (ad == adViewRectangle) {
        setLabel("");
    }
}
项目:kognitivo    文件:RectangleFragment.java   
@Override
public void onAdClicked(Ad ad) {
    Toast.makeText(this.getActivity(), "Ad Clicked", Toast.LENGTH_SHORT).show();
}
项目:kognitivo    文件:BannerFragment.java   
@Override
public void onError(Ad ad, AdError error) {
    if (ad == adViewBanner) {
        setLabel("Ad failed to load: " + error.getErrorMessage());
    }
}
项目:kognitivo    文件:BannerFragment.java   
@Override
public void onAdLoaded(Ad ad) {
    if (ad == adViewBanner) {
        setLabel("");
    }
}
项目:kognitivo    文件:BannerFragment.java   
@Override
public void onAdClicked(Ad ad) {
    Toast.makeText(this.getActivity(), "Ad Clicked", Toast.LENGTH_SHORT).show();
}
项目:kognitivo    文件:InterstitialFragment.java   
@Override
public void onError(Ad ad, AdError error) {
    if (ad == interstitialAd) {
        setLabel("Interstitial ad failed to load: " + error.getErrorMessage());
    }
}
项目:kognitivo    文件:InterstitialFragment.java   
@Override
public void onAdLoaded(Ad ad) {
    if (ad == interstitialAd) {
        setLabel("Ad loaded. Click show to present!");
    }
}
项目:kognitivo    文件:InterstitialFragment.java   
@Override
public void onInterstitialDisplayed(Ad ad) {
    Toast.makeText(this.getActivity(), "Interstitial Displayed", Toast.LENGTH_SHORT).show();
}
项目:kognitivo    文件:InterstitialFragment.java   
@Override
public void onAdClicked(Ad ad) {
    Toast.makeText(this.getActivity(), "Interstitial Clicked", Toast.LENGTH_SHORT).show();
}
项目:sekai    文件:NativeAdSampleActivity.java   
@Override
public void onError(Ad ad, AdError error) {
    nativeAdStatus.setText("Ad failed to load: " + error.getErrorMessage());
}
项目:sekai    文件:NativeAdSampleActivity.java   
@Override
public void onAdClicked(Ad ad) {
    Toast.makeText(this, "Ad Clicked", Toast.LENGTH_SHORT).show();
}
项目:sekai    文件:RectangleFragment.java   
@Override
public void onError(Ad ad, AdError error) {
    if (ad == rectangleAdView) {
        setLabel("Ad failed to load: " + error.getErrorMessage());
    }
}