In Feed

Scenario

  • Insert ad into ListView/RecyclerView when user is scrolling it.

Ad Formats Supported

  • Card Ad

  • Native Ad

How to Integrate

CrystalExpress™ SDK provides CEInFeedHelper to simplify in-feed integration of Card Ad and Native Ad. Please follow the step below:

Step 1: Copy the adsource, component under infeed folder.

You can modify the CEIFNativeAdView.java /CEIFDisplayAdView.java to customize the ad view.

Step 2: Prepare placement

  • You can have only one placement for a given RecyclerVIew/ListView.

  • The placement also could be obtained from your backend server to improve the scalability.

Step 3: Initialize CEInFeedHelper

  • If your app consists of multiple RecyclerVIew/ListView, each RecyclerView/ListView needs to be associated with one CEInFeedHelper.

Step 4: Initial and Add ad source to CEInFeedHelper

The CEIFAdSource define the ad format you want to show on the feed placement.

  • For Card Ad format, please initialize CEIFDisplayAdSource.

For more detail of customizing ad props, you can refer to AdProperty

  • For Native Ad format, please initialize CEIFNativeAdSource.

For more detail of customizing ad props, you can refer to AdProperty

Step 5 (Optional) : Set ad event listener if you want to receive ad event status.

If you want to track the impression, click, mute.... etc, you can implement the CEIFHelperAdEventListener to override the corresponding function.

Step 6

Case 1 (Recommend): Put your adapter and CEInFeedHelper into CEIFAdapter()/CEIFRecyclerViewAdapter()

The CEIFAdapter/CEIFRecyclerViewAdapter can handle perform dynamic ad insertion and placement management. You can integrate the related adapter according to

  • ListView: Please use CEIFAdapter

  • RecyclerView: Please use CEIFRecyclerViewAdapter

Case 2: Get the Ad View from CEInFeedHelper each time in onBindViewHolder to make sure the ad can insert into your dataset in order.

If you want to assign Ad position by your own, you can pass the step6, and handle the content order as you prefer or contact your solutions engineer.

Step 7 : Implement the RecyclerView.OnScrollListener to notify InFeedHelper the scroll and scroll state.

The CEInFeedHelper needs to know the scroll state to make sure whether to prepare the Ad.

Step 8: Add helper.onDestroy() and adapter.onDestroy()in the Activity.onDestroy() for memory release

Last updated