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 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.
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); ViewGroup adView = InterscrollerContainer.getAdView(context); return new RecyclerView.ViewHolder(adView){}; }
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); placement.setShowHeader(true); placement.setReveal(true); placement.setShowTapHint(true); InterscrollerContainer container = placement .getContainer(context, requestId, position); //position is optional, could be null 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
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.
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); // use next methods to customize UI (optional) headlinePlacement.setBackgroundInfeedColor(Color.RED); headlinePlacement.setTitleInfeedColor(Color.YELLOW); headlinePlacement.setAdvertiserNameInfeedColor(Color.MAGENTA); headlinePlacement.setButtonTextInfeedColor(Color.BLACK); headlinePlacement.setButtonBackgroundInfeedColor(Color.TRANSPARENT headlinePlacement.setButtonContourInfeedColor(Color.GREEN); headlinePlacement.setBackgroundHeadlineColor(Color.GREEN); headlinePlacement.setTitleHeadlineColor(Color.DKGRAY); headlinePlacement.setAdvertiserNameHeadlineColor(Color.BLUE); headlinePlacement.setButtonTextHeadlineColor(Color.GREEN); headlinePlacement.setButtonBackgroundHeadlineColor(Color.WHITE); headlinePlacement.setButtonContourHeadlineColor(Color.YELLOW); headlinePlacement.setSwipeOffLineColor(Color.BLACK); headlinePlacement.setTitleText("Some title"); headlinePlacement.setAllowSwipeOff(false); headlinePlacement.setHeadlineMode(false); headlinePlacement.setButtonText("Click me"); 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.
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"); } });
Interstitial
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.
Our Interstitial ad unit supports fullscreen ads of Video and Display (Static and Rich-Media) ad formats over portrait and landscape orientations. Ad Unit size is 480×320/320×480.
Displaying Interstitial Ads
To show an Interstitial ad you need to call the Ad’s showAd() method.
ad.showAd(Context context); /// optionally set delay for close button (5 sec by default) interstitialPlacement.setCloseButtonDelay(5);
Note: After showing an ad you may not show it again. Process another AdRequest to get a new ad.
Check the Sample App for a fully-working example.