本文整理汇总了Java中com.facebook.ads.NativeAd类的典型用法代码示例。如果您正苦于以下问题:Java NativeAd类的具体用法?Java NativeAd怎么用?Java NativeAd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NativeAd类属于com.facebook.ads包,在下文中一共展示了NativeAd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addNativeAd
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public synchronized void addNativeAd(NativeAd ad, Context context, ArrayList<TimelineListAPKsJson.UserApk> list) {
if (ad == null) {
Log.d("pois", "addNativeAd , was null");
return;
}
if (this.ad != null) {
Log.d("pois","addNativeAd , was old");
// Clean up the old ad before inserting the new one
this.ad.unregisterView();
list.remove(AD_INDEX);
this.ad = null;
this.notifyDataSetChanged();
}
Log.d("pois","addNativeAd , adding native ad");
this.ad = ad;
adView = mInflater.inflate(R.layout.row_timeline_ad_unit, null);
TimelineListAPKsJson.UserApk ret = new UserAPKAd(ad);
inflateAd(ad, adView, context);
list.add(AD_INDEX, ret);
Log.d("pois","addNativeAd , position on "+AD_INDEX);
this.notifyDataSetChanged();
}
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:23,代码来源:TimelineAdapter.java
示例2: onCreate
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hscroll);
manager = new NativeAdsManager(this, "YOUR_PLACEMENT_ID", 5);
manager.setListener(this);
manager.loadAds(NativeAd.MediaCacheFlag.ALL);
inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
reloadButton = (Button)findViewById(R.id.reloadHscroll);
reloadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.loadAds();
}
});
}
开发者ID:ecaroff,项目名称:sekai,代码行数:20,代码来源:NativeAdHscrollActivity.java
示例3: request
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
if (context == null || networkData == null) {
invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
} else {
mContext = context;
String placementId = networkData.get(Facebook.KEY_PLACEMENT_ID);
if (TextUtils.isEmpty(placementId)) {
invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
} else {
mAdView = null;
mWrapper = null;
Facebook.init(context);
mNativeAd = new NativeAd(context, placementId);
mNativeAd.setAdListener(this);
mNativeAd.loadAd();
}
}
}
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:21,代码来源:FacebookNetworkAdapter.java
示例4: request
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
if (context == null || networkData == null) {
invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
} else {
mContext = context;
String placementId = networkData.get(Facebook.KEY_PLACEMENT_ID);
if (TextUtils.isEmpty(placementId)) {
invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
} else {
Facebook.init(context);
mAdView = null;
mWrapper = null;
mNativeAd = new NativeAd(context, placementId);
mNativeAd.setAdListener(this);
mNativeAd.loadAd();
}
}
}
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:20,代码来源:FacebookNetworkAdapter.java
示例5: addNativeAd
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public synchronized void addNativeAd(NativeAd ad) {
if (ad == null) {
return;
}
if (this.ad != null) {
// Clean up the old ad before inserting the new one
this.ad.unregisterView();
this.datas.remove(AD_INDEX);
this.ad = null;
this.notifyDataSetChanged();
}
this.ad = ad;
View adView = inflater.inflate(R.layout.ad_list, null);
inflateAd(ad, adView);
datas.add(AD_INDEX, adView);
this.notifyDataSetChanged();
}
开发者ID:aknkaplanoglu,项目名称:Sportmix,代码行数:19,代码来源:PostItemAdapter.java
示例6: addNativeAd
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public synchronized void addNativeAd(NativeAd ad) {
if (ad == null) {
return;
}
if (this.ad != null) {
// Clean up the old ad before inserting the new one
this.ad.unregisterView();
this.list.remove(AD_INDEX);
this.ad = null;
this.notifyDataSetChanged();
}
this.ad = ad;
View adView = inflater.inflate(R.layout.ad_unit, null);
NativeAdSampleActivity.inflateAd(ad, adView, NativeAdListActivity.this);
list.add(AD_INDEX, adView);
this.notifyDataSetChanged();
}
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:18,代码来源:NativeAdListActivity.java
示例7: onAdLoaded
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public void onAdLoaded(Ad ad) {
Logger.d("FragmentSocialTimeline","onAdLoaded , ad: "+ad.toString());
if(getActivity() != null){
adapter.addNativeAd((NativeAd) ad,getActivity(),apks);
}
}
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:9,代码来源:FragmentSocialTimeline.java
示例8: onAdLoaded
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@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);
}
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:34,代码来源:FacebookNativeAd.java
示例9: FacebookNativeAdModel
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public FacebookNativeAdModel(Context context, NativeAd nativeAd) {
super(context);
if (nativeAd != null) {
mNativeAd = nativeAd;
mNativeAd.setAdListener(this);
}
}
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:8,代码来源:FacebookNativeAdModel.java
示例10: getStarRating
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public float getStarRating() {
float starRating = 0;
if (mNativeAd != null) {
NativeAd.Rating rating = mNativeAd.getAdStarRating();
if (rating != null) {
double ratingScale = rating.getScale();
double ratingValue = rating.getValue();
starRating = (float) ((ratingValue / ratingScale) * 5);
}
}
return starRating;
}
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:14,代码来源:FacebookNativeAdModel.java
示例11: onAdLoaded
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public void onAdLoaded(Ad ad) {
if (ad == mNativeAd) {
FacebookNativeAdModel wrapModel = new FacebookNativeAdModel(mContext, (NativeAd) ad);
wrapModel.setInsightModel(mInsight);
invokeLoadFinish(wrapModel);
}
}
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:9,代码来源:FacebookNetworkAdapter.java
示例12: 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
示例13: FacebookNativeAd
import com.facebook.ads.NativeAd; //导入依赖的package包/类
FacebookNativeAd(final Context context,
final NativeAd nativeAd,
final CustomEventListener customEventListener) {
mContext = context.getApplicationContext();
mFbNativeAd = nativeAd;
mCustomEventListener = customEventListener;
}
开发者ID:picatcha,项目名称:adsnative-sdk-android,代码行数:8,代码来源:FacebookAdNetwork.java
示例14: requestNativeAd
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@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();
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:37,代码来源:FacebookAdapter.java
示例15: getRating
import com.facebook.ads.NativeAd; //导入依赖的package包/类
/**
* Convert rating to a scale of 1 to 5.
*/
private Double getRating(NativeAd.Rating rating) {
if (rating == null) {
return null;
}
return (MAX_STAR_RATING * rating.getValue()) / rating.getScale();
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:10,代码来源:FacebookAdapter.java
示例16: onAdsLoaded
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public void onAdsLoaded() {
//This method will download ad from FB
//& call addNativeAd method which will add ad to listview
NativeAd ad = this.listNativeAdsManager.nextNativeAd();
ad.setAdListener(this);
if (itemAdapter!=null)
itemAdapter.addNativeAd(ad); //postitemadaptere tanımlıyoruz.
}
开发者ID:aknkaplanoglu,项目名称:Sportmix,代码行数:12,代码来源:FotomacFragment.java
示例17: onAdsLoaded
import com.facebook.ads.NativeAd; //导入依赖的package包/类
@Override
public void onAdsLoaded() {
//This method will download ad from FB
//& call addNativeAd method which will add ad to listview
NativeAd ad = this.listNativeAdsManager.nextNativeAd();
ad.setAdListener(this);
if (itemAdapter!=null)
itemAdapter.addNativeAd(ad); //postitemadaptere tanımlıyoruz.
}
开发者ID:aknkaplanoglu,项目名称:Sportmix,代码行数:12,代码来源:SporxFragment.java
示例18: 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
示例19: onCreate
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listNativeAd = new NativeAd(this, "YOUR_PLACEMENT_ID");
listNativeAd.setAdListener(this);
listNativeAd.loadAd();
listView = getListView();
adapter = new ListViewAdapter(getApplicationContext());
listView.setAdapter(adapter);
}
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:12,代码来源:NativeAdListActivity.java
示例20: FBNativeAdResponse
import com.facebook.ads.NativeAd; //导入依赖的package包/类
public FBNativeAdResponse(NativeAd ad) {
this.nativeAd = ad;
runnable = new Runnable() {
@Override
public void run() {
if (coverImage != null) {
coverImage.recycle();
coverImage = null;
}
if (icon != null) {
icon.recycle();
icon = null;
}
listener = null;
expired = true;
if (nativeAd != null) {
nativeAd.setAdListener(null);
nativeAd.destroy();
nativeAd = null;
}
if(nativeElements != null && !nativeElements.isEmpty()){
nativeElements.clear();
}
}
};
fbNativeExpireHandler = new Handler(Looper.getMainLooper());
fbNativeExpireHandler.postDelayed(runnable, Settings.NATIVE_AD_RESPONSE_EXPIRATION_TIME);
}
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:29,代码来源:FBNativeAdResponse.java
注:本文中的com.facebook.ads.NativeAd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论