Interscroller ad unit is an Interstitial ad format in a feedwhich provides a unique and engaging user experience.

Interscroller enables you to insert an advertisement inside your app’s feed, while displaying ad-content in fullscreen, in order to command high CPM payouts.

The best performance can be reached using reveal effect and customizing colors of visible view-elements.

Interscroller ad unit supports both Video and Display (Static and Rich-Media) ad formats over portrait orientations.

  • Display and Rich Media ad size = 320×480
  • VAST Vertical Video ad size = 360×640

Interscroller ads have been designed to be integrated into recycle views. Best practice dictates extending your  RecyclerView.Adapter and RecyclerView.ViewHolder (AdHolder as an example), in order to pass the relevant Placement and AdRequest IDs:

static class AdHolder extends RecyclerView.ViewHolder {
    public ViewGroup parent;
    AdHolder(View itemView) {
        super(itemView);
    }
}

It is important to call setParentRecyclerView(recyclerView) on InterscrollerPlacement. It is not nesessary to call it withing RecyclerView adapter, you can set the RecyclerView to placement anywhere in code when you have a reference to your RecyclerView.  Use InterscrollerContainer.getAdView(Context context) method to get  the ad view and return it in a ViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    context = parent.getContext().getApplicationContext();
   if (viewType == AD_VIEW_TYPE) {
    InterscrollerPlacement placement = (InterscrollerPlacement)Controller
                                        .getInstance().getPlacement(placementId);
    placement.setParentRecyclerView(recyclerView);

ViewGroup adView = InterscrollerContainer.getAdView(context);
AdHolder adHolder = new AdHolder(adView);
return adHolder;
}

Inside the adapter’s onBindViewHolder you will need to retrieve a InterscrollerContainer object from the Placement object by calling it’s getContainer method and passing it the ApplicationContext and the AdRequest id as parameters. Then use the InterscrollerContainer.bindTo method to bind the Ad to the ViewHolder’s itemView.

@Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
        if (holder.getItemViewType() == 0 && holder instanceof AdHolder) {
            try {
                InterscrollerPlacement placement = (InterscrollerPlacement)Controller.getInstance().getPlacement(placementId);
                     // use next methods to customize UI (optional)
                placement.setFooterBackgroundColor(int color);
                placement.setHeaderBackgroundColor(int color);
                placement.setFooterColor(int color);
                placement.setHeaderColor(int color);
                placement.setBackgroundColor(int color);

               InterscrollerContainer container = placement
                         .getContainer(context, requestId, position);
               container.bindTo((ViewGroup) holder.itemView);
              } catch (DioSdkException e) {
                             // error handling
                    }
            }
     }

If you use dynamic widgets or just want to set different height or different top offset to Interscroller you can set it calling:

container.setInterscrollerHeight(int interscrollerHeight);
container.setInterscrollerOffset(int interscrollerOffset);

Note: Interscroller will appear in case it is loaded before RecyclerViev called onBindViewHolder for it’s position. If you want Interscroller to expand after (in the middle of the screen) you have to call notifyDataSetChanged() on adapter after the ad is loaded:

recyclerView.getAdapter().notifyDataSetChanged();

Before your activity is destroyed, OR, to remove the ad:  ad.close() to stop the ad and release the resources associated with it.

 try {
          Controller.getInstance()
                .getPlacement(<placementId>)
                .getAdRequestById(<requestId>)
                .getAdProvider().getAd().close();
     } catch (DioSdkException e) {
        // error handling
  }

Check the Sample App for a fully-working example.

Headline

Headline is a video and display ad format that provides an option to attach the ad to the top of the feed UI as the user scrolls through their feed.

Headline ads are designed to be integrated into recycler views. The best practice is to extend your  RecyclerView.Adapter and RecyclerView.ViewHolder (AdHolder is available in the example below), in order to pass the relevant Placement and AdRequest IDs .

Inside the adapter’s onCreateViewHolder use
HeadlineAdContainer.getAdView(Context context) method to get the ad view and return it in a ViewHolder.

Inside the adapter’s onBindViewHolder you will need to retrieve HeadlineAdContainer object from the Placement object by calling it’s getHeadlineContainer method and passing it the ApplicationContext and the AdRequest id as parameters. Then use headlineAdContainer.bindTo method to bind the Ad to the ViewHolder’s itemView.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent,
 int viewType) {
     context = parent.getContext().getApplicationContext();
     RelativeLayout adView = HeadlineAdContainer.getAdView(context);
     return new AdHolder(adView);
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, 
int position) 
{
     try {
        HeadlinePlacement headlinePlacement = 
              (HeadlinePlacement) Controller.getInstance()
              .getPlacement(placementId);
        headlinePlacement.setTextColor(Color.RED);
        headlinePlacement.setExpandedBackgroundColor(Color.BLACK);
        headlinePlacement.setCollapsedBackgroundColor(Color.BLUE);
        headlinePlacement.setSponsoredText("My custom text");
        headlinePlacement.setLearnMoreText("My custom text");
        HeadlineAdContainer container = headlinePlacement 
             .getHeadlineContainer(context, requestId);
        container.bindTo((ViewGroup) holder.itemView);
     } catch (DioSdkException e) {
          // error handling
     }
}

In order to customize frame and text colors use optional setters on HeadlinePlacement object as showed in example.

Note: Headline ad will appear in case it is loaded before RecyclerViev called onBindViewHolder for it’s position. If you want Headline to expand after (in the middle of the screen) you have to call notifyDataSetChanged() on adapter after the ad is loaded:

recyclerView.getAdapter().notifyDataSetChanged();

There are additional methods available in order to control behavior in case of switching between  fragments:

  • Call (HeadlineAdInterface)ad.finishHeadlineSession() to stop the ad and release the resources associated with it.

And for video ads:

  • Call ad.leave() to pause the video ad.
  • Call ad.reenter() to resume the video ad. It is very important to notify SDK with these methods in order to get best performance and stable work.
To use the ‘snap-animation’ feature for Headline ad unit when attaching the ad to the top of the feed UI you should add HeadlineSnapListener to recyclerView and implement an additional method, which defines how to remove the ad position from a feed.
Reference the code below as an example:
recyclerView.addOnScrollListener(new HeadlineSnapListener(AD_POSITION) {
    @Override
    public void removeAdPositionFromList(int adPosition) {
        items.remove(adPosition); // items is a dataset for your adapter
        adapter.notifyDataSetChanged(); 
    }
    @Override
    public void onAdSwipedOut() {
      Log.d(TAG, "User closed video with swipe");
   }
 });
Check the Sample App for a fully-working example.