Search in sources :

Example 1 with LetterItem

use of com.mikepenz.fastadapter.app.items.LetterItem 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);
}
Also used : LetterItem(com.mikepenz.fastadapter.app.items.LetterItem) MoPubRecyclerAdapter(com.mopub.nativeads.MoPubRecyclerAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ViewBinder(com.mopub.nativeads.ViewBinder) MoPubStaticNativeAdRenderer(com.mopub.nativeads.MoPubStaticNativeAdRenderer)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LetterItem (com.mikepenz.fastadapter.app.items.LetterItem)1 MoPubRecyclerAdapter (com.mopub.nativeads.MoPubRecyclerAdapter)1 MoPubStaticNativeAdRenderer (com.mopub.nativeads.MoPubStaticNativeAdRenderer)1 ViewBinder (com.mopub.nativeads.ViewBinder)1