Feed Type (2.0)

BuzzAd Benefit SDK: Feed


This documentation provides a guideline for integrating feed for BuzzAd Benefit.

※ Note

  1. Please proceed with the following process only after BuzzAd Benefit SDK integration is complete.

  2. The feed accommodates customization of the design of toolbar, ad list item and header.

  3. Please proceed with the Advanced Usage only after implementing all of the features in Basic Usage.

 

Index

 

Basic Usage


Setting the FeedConfig and the FeedHandler

  1. Create the FeedConfig with unit_id.

  2. Create a FeedHandler using the the FeedConfig as its object.

  3. Call startFeedActivity() to start a feed activity.

 

final FeedConfig feedConfig = new FeedConfig.Builder(context, "YOUR_FEED_UNIT_ID").build(); final FeedHandler feedHandler = new FeedHandler(feedConfig); feedHandler.startFeedActivity(this);

 


Checking for the Ad Status

At times, directly calling startFeedActivity() may result in a blank screen when there are no ads available. Therefore, it is recommended to call preload() and call onPreloaded() to check the ad status so that feed activity can be started only when there are ads available.

  • feedHandler.getSize() : The number of ads

  • feedHandler.getTotalReward() : The total amount of reward available

 

feedHandler.preload(new FeedHandler.FeedPreloadListener() { @Override public void onPreloaded() { int feedAdSize = feedHandler.getSize(); int feedTotalReward = feedHandler.getTotalReward(); } @Override public void onError(AdError error) { // on load failure, error explains why the load failed } });

 

Note

  • The method startFeedActivity() must be called on the same object as the preloaded FeedHandler.

    • Attention : If ads are preloaded in a FeedHandler instance, the instance will continue to hold the same ads. Hence, even if the user leaves the activity, calling the startFeedActivity() with the same instance will display the same preloaded ads. By calling startFeedActivity() with a new FeedHandler, new ads will be shown each time the feed activity is started.

  • The preload feature may not work if the FeedHandler is declared as a local variable since weakReference is implemented for the object to prevent memory leaks. Hence, please declare the FeedHandler as non-local variable.

 

// Example of declaring FeedHandler as a local variable private void preloadFeed() { // The below listener may not work as FeedHandler might get deleted from the memory. final FeedHandler feedHandler = new FeedHandler(getFeedConfig()); feedHandler.preload(new FeedHandler.FeedPreloadListener() { @Override public void onPreloaded() { // may not work } @Override public void onError(AdError error) { // may not work } }); }


Advanced Usage


Design Customization

Important

  • When creating a custom class for the FeedToolbarHolder, FeedAdsAdapter, FeedHeaderViewAdapter, one of the following conditions must be followed:

    1. Each class must not be an inner class.

    2. If created as an inner class, it must be declared as a public static class.

  • If the above conditions are not met, the class cannot be found and customization will not be applied.

 

ToolBar Customization

The design of the toolbar at the top of the feed can be customized.

  1. Create a class that implements FeedToolbarHolder.




  2. Specify the FeedToolbarHolder when building the FeedConfig.


     

Changing the Height of the ToolBar

The height value of the layout for the customized toolbar is fixed by default. To modify the height value, add the following code below.

 

 

Customizing the Header

Customizing the header can be done to provide more information to the users.

  1. Create a class that implements FeedHeaderViewAdapter.




  2. Specify the FeedHeaderViewAdapter when building the FeedConfig.


 

Customizing the Feed Ad List View

The ad list view of the feed can be customized and callbacks for ad events can be registered.

  1. Implement a class that inherits AdsAdapter.

    1. Implement onCreateViewHolder and onBindViewHolder to customize the layout and the binding logic of itemView to display in the feed list.

    2. getCtaTextView () and getRewardImageView () methods can be called to customize the text and reward images shown in the CtaView. (See CtaView Customization below for more flexibility in customization)

    3. (optional) Implement necessary customizations for the state-specific callbacks for the ad. (Refer to the document for event definitions and actions).




  2. Specify the AdsAdapter when building the FeedConfig.


 

CtaView (Button) Customization

To implement the CtaView differently from the default view, please proceed as follows.

 

 

※ Note

There may be times when reward is not available for an ad either because only a very short time has passed since the user has been rewarded for the same ad or because the ad did not have reward to begin with. Therefore, when configuring the ad layout, please check to see the availability of a reward to decide whether to show the reward on the UI or not (see sample code below).

 

 

Using the FeedFragment

FeedFragment can be used to display feed differently from that of the FeedActivity

  • The basic usage of FeedFragment




  • For FeedFragment, preload() can be used by creating a FeedHandler without calling startFeedActivity().

  • FeedFragment accommodates the customization of AdsAdapter, with the exception of toolbar, and header is available by using feedConfig.

To refresh ads in the fragment, FeedHandler needs to be created before initializing the FeedFragment.