use of com.mopub.nativeads.ViewBinder in project FastAdapter by mikepenz.
the class MopubAdsActivity method onCreate.
@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);
}
Aggregations