本文整理汇总了Java中com.mopub.nativeads.ViewBinder类的典型用法代码示例。如果您正苦于以下问题:Java ViewBinder类的具体用法?Java ViewBinder怎么用?Java ViewBinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewBinder类属于com.mopub.nativeads包,在下文中一共展示了ViewBinder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initMoPub
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
private void initMoPub(@NonNull final String adUnitId) {
this.moPubNative = new MoPubNative(this, adUnitId, this);
this.moPubNative.registerAdRenderer(new MoPubStaticNativeAdRenderer(new ViewBinder.Builder(R.layout.view_native_ad)
.titleId(R.id.ad_title)
.textId(R.id.ad_body)
.mainImageId(R.id.ad_image)
.callToActionId(R.id.ad_call_to_action)
.build()));
}
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:10,代码来源:MainActivity.java
示例2: fetchAd
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
public void fetchAd(final Context context) {
MoPubNative moPubNative = new MoPubNative(context, BuildConfig.MOPUB_NATIVE_AD_UNIT_ID,
new MoPubNative.MoPubNativeNetworkListener() {
@Override public void onNativeLoad(NativeAd nativeAd) {
View view = nativeAd.createAdView(context, null);
nativeAd.clear(view);
nativeAd.renderAdView(view);
nativeAd.prepare(view);
ad.call(new AdResponse(view, AdResponse.Status.ok));
}
@Override public void onNativeFail(NativeErrorCode nativeErrorCode) {
ad.call(new AdResponse(null, AdResponse.Status.error));
}
});
ViewBinder viewBinder =
new ViewBinder.Builder(R.layout.mopub_native_ad).mainImageId(R.id.timeline_ad_image)
.iconImageId(R.id.card_image)
.titleId(R.id.card_title)
.textId(R.id.timeline_ad_description)
.callToActionId(R.id.timeline_ad_button)
.build();
MoPubStaticNativeAdRenderer adRenderer = new MoPubStaticNativeAdRenderer(viewBinder);
moPubNative.registerAdRenderer(adRenderer);
moPubNative.makeRequest(new RequestParameters.Builder().desiredAssets(
EnumSet.of(RequestParameters.NativeAdAsset.TITLE, RequestParameters.NativeAdAsset.TEXT,
RequestParameters.NativeAdAsset.MAIN_IMAGE, RequestParameters.NativeAdAsset.ICON_IMAGE,
RequestParameters.NativeAdAsset.CALL_TO_ACTION_TEXT))
.build());
}
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:32,代码来源:TimelineAdsRepository.java
示例3: onCreate
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up your adapter as usual.
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1);
for (int i = 0; i < 100; ++i) {
adapter.add("Item " + i);
}
// Set up a ViewBinder and MoPubNativeAdRenderer as above.
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.mopub_layout)
.iconImageId(R.id.native_icon)
.titleId(R.id.native_title)
.textId(R.id.native_text)
.callToActionId(R.id.native_cta)
.privacyInformationIconImageId(R.id.native_ad_privacy)
.build();
// Set up the positioning behavior your ads should have.
MoPubNativeAdPositioning.MoPubServerPositioning adPositioning = MoPubNativeAdPositioning.serverPositioning();
MoPubStaticNativeAdRenderer adRenderer = new MoPubStaticNativeAdRenderer(viewBinder);
// Set up the MoPubAdAdapter
mAdAdapter = new MoPubAdAdapter(getActivity(), adapter, adPositioning);
mAdAdapter.registerAdRenderer(adRenderer);
setListAdapter(mAdAdapter);
}
开发者ID:Pocketbrain,项目名称:androidnativeadslib,代码行数:30,代码来源:MoPubIntegrationFragment.java
示例4: onCreate
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_native_ad);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle("Native Ad");
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ListView sampleListView = (ListView) findViewById(R.id.mopub_sample_list_view);
ArrayList<String> sampleItems = new ArrayList<>();
for (int i = 1; i <= 20; i++) {
sampleItems.add("Item " + i);
}
ArrayAdapter<String> sampleAdapter = new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_1,
sampleItems
);
//Set up native ads
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_layout)
.mainImageId(R.id.native_ad_main_image)
.iconImageId(R.id.native_ad_icon_image)
.titleId(R.id.native_ad_title)
.textId(R.id.native_ad_text)
.build();
// Set up the positioning behavior your ads should have.
MoPubNativeAdPositioning.MoPubServerPositioning adPositioning =
MoPubNativeAdPositioning.serverPositioning();
MoPubNativeAdRenderer adRenderer = new MoPubNativeAdRenderer(viewBinder);
// Set up the MoPubAdAdapter
mAdAdapter = new MoPubAdAdapter(this,sampleAdapter, adPositioning);
mAdAdapter.registerAdRenderer(adRenderer);
sampleListView.setAdapter(mAdAdapter);
}
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:41,代码来源:NativeAdActivity.java
示例5: setUpPoemList
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
private void setUpPoemList() {
shareListener = new OnShareClickListener();
deleteListener = new OnDeleteClickListener();
final ListView poemsList = (ListView) findViewById(R.id.poem_history_list);
adapter = new PoemCursorAdapter(
getApplicationContext(),
null,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
// MoPub integration
final ViewBinder mopubViewBinder = new ViewBinder.Builder(R.layout.native_ad_layout)
.mainImageId(R.id.native_ad_main_image)
.iconImageId(R.id.native_ad_icon_image)
.titleId(R.id.native_ad_title)
.textId(R.id.native_ad_text)
.build();
MoPubNativeAdPositioning.MoPubServerPositioning adPositioning =
MoPubNativeAdPositioning.serverPositioning();
final MoPubNativeAdRenderer adRenderer = new MoPubNativeAdRenderer(mopubViewBinder);
moPubAdAdapter = new MoPubAdAdapter(this, adapter, adPositioning);
moPubAdAdapter.registerAdRenderer(adRenderer);
poemsList.setAdapter(moPubAdAdapter);
}
开发者ID:crashlytics,项目名称:cannonball-android,代码行数:28,代码来源:PoemHistoryActivity.java
示例6: onCreate
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content)
.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
// Handle Toolbar
setSupportActionBar(toolbar);
mAdapter = new MopubFastItemAdapter<>();
mAdapter.withOnClickListener(this);
for (int i = 65; i <= 90; i++) {
mAdapter.add(new LetterItem(String.valueOf((char) i)));
}
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_item)
.iconImageId(R.id.native_icon_image)
.titleId(R.id.native_title)
.textId(R.id.native_text)
.callToActionId(R.id.native_cta)
.privacyInformationIconImageId(R.id.native_privacy_information_icon_image)
.build();
MoPubRecyclerAdapter adapter = new MoPubRecyclerAdapter(this, mAdapter);
adapter.registerAdRenderer(new MoPubStaticNativeAdRenderer(viewBinder));
adapter.loadAds("76a3fefaced247959582d2d2df6f4757");
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 1));
mRecyclerView.setAdapter(adapter);
//provide the mopub adapter
mAdapter.withMoPubAdAdapter(adapter);
//restore selections (this has to be done after the items were added
mAdapter.withSavedInstanceState(savedInstanceState);
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:MopubAdsActivity.java
示例7: onCreateView
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.recycle_fragment, container, false);
mDatabase = FirebaseUtils.getDatabase().getReference();
final List<Recipe> recipes = new ArrayList<>();
loadItens();
Query recipesQuery = getQuery(mDatabase);
adapter = new RecipesAdapter(recipes, recipesQuery);
myMoPubAdapter = new MoPubRecyclerAdapter(getActivity(), adapter);
// Create an ad renderer and view binder that describe your native ad layout.
ViewBinder myViewBinder = new ViewBinder.Builder(R.layout.ad_item)
.titleId(R.id.tv_ad_title)
.textId(R.id.tv_ad_description)
.mainImageId(R.id.iv_ad_main_image)
.iconImageId(R.id.iv_ad_icon)
.callToActionId(R.id.btn_ad_call_to_action)
.build();
MoPubStaticNativeAdRenderer myRenderer = new MoPubStaticNativeAdRenderer(myViewBinder);
myMoPubAdapter.registerAdRenderer(myRenderer);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler);
mRecyclerView.setAdapter(myMoPubAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recipesQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
recipes.clear();
Log.d(TAG, getResources().getString(R.string.onDataChange));
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
Recipe item = postSnapshot.getValue(Recipe.class);
item.setUid(postSnapshot.getKey());
Log.d(TAG, item.getName()+ getResources().getString(R.string.canbemade) +item.canBeMade(stock));
if(!shouldCheckStock() || item.canBeMade(stock)) {
recipes.add(item);
}
}
adapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d(TAG, getResources().getString(R.string.onCancelled));
}
});
return view;
}
开发者ID:WilderPereira,项目名称:Reciclo,代码行数:59,代码来源:ListFragment.java
示例8: onCreateView
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container,
final Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
final View view = inflater.inflate(R.layout.fragment_native_ad, container, false);
final RelativeLayout nativeAdContainer = (RelativeLayout) view.findViewById(R.id.native_ad);
final ViewBinder viewBinder = new ViewBinder.Builder(R.layout.fan_native_layout_backup)
.mainImageId(R.id.an_main_image)
.iconImageId(R.id.an_icon_image)
.titleId(R.id.an_title)
.textId(R.id.an_summary)
.callToActionId(R.id.an_call_to_action)
.privacyInformationIconImageId(R.id.an_ad_choices)
.build();
MoPubNative.MoPubNativeNetworkListener moPubNativeListener = new MoPubNative.MoPubNativeNetworkListener() {
@Override
public void onNativeLoad(NativeAd nativeAd) {
ANLog.e("onNativeLoad");
nativeAdContainer.addView(renderAd(nativeAd, viewBinder));
}
@Override
public void onNativeFail(NativeErrorCode errorCode) {
// ...
}
};
moPubNative = new MoPubNative(this.getContext(), MOPUB_AD_UNIT_ID, moPubNativeListener);
MoPubStaticNativeAdRenderer moPubStaticNativeAdRenderer = new MoPubStaticNativeAdRenderer(viewBinder);
moPubNative.registerAdRenderer(moPubStaticNativeAdRenderer);
PolymorphBidder polymorphBidder = new PolymorphBidder(this.getContext());
polymorphBidder.loadMopubAd(PM_AD_UNIT_ID, moPubNative, null);
// moPubNative.makeRequest();
return view;
}
开发者ID:picatcha,项目名称:adsnative-sdk-android,代码行数:44,代码来源:MoPubNativeAd.java
示例9: renderAd
import com.mopub.nativeads.ViewBinder; //导入依赖的package包/类
private View renderAd(NativeAd nativeAd, ViewBinder viewBinder) {
AdapterHelper adapterHelper = new AdapterHelper(this.getContext(), 0, 3);
View view = adapterHelper.getAdView(null, null, nativeAd, viewBinder);
return view;
}
开发者ID:picatcha,项目名称:adsnative-sdk-android,代码行数:6,代码来源:MoPubNativeAd.java
注:本文中的com.mopub.nativeads.ViewBinder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论