Before You Start Make Sure:
- App and Placement set up on Publisher Portal
- SDK is installed
- SDK is initialized
- Each Ad request has "Testing" status which enables it to test integrations.
Interscroller is a new ad unit, which combines the best elements of both Infeed and Interstitial ad units, in order to provide a unique, 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 customising 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 = 320x480
- VAST Vertical Video ad size = 360x640
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 necessary to call it within 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 customise 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);
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.
Comments
0 comments
Please sign in to leave a comment.