Before You Start Make Sure:
- Inventory is set up on Retailer Portal
- SDK is integrated
- Placements have status “Testing”, which enables testing ads with 100% fill
Shopable Video
Shopable Video ad unit is 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 .
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // create your ad holder here, could be any ViewGroup } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { try { ShoppablePlacement shoppablePlacement = (ShoppablePlacement) Controller.getInstance() .getPlacement(placementId); shoppablePlacement.setAdContainerContour(Color.GREY); shoppablePlacement.setAdContainerBackground(Color.WHITE); shoppablePlacement.setSponsoredText("Sponsored"); shoppablePlacement.setSponsoredText(Color.BLACK); shoppablePlacement.setProductNameText(Color.BLACK); shoppablePlacement.setProductRateStarsBackground(Color.BLACK); shoppablePlacement.setProductRateStarsColor(Color.YELLOW); shoppablePlacement.setProductReviewsText(Color.GREY); shoppablePlacement.setProductPriceText(Color.BLACK); shoppablePlacement.setProductInfoText(Color.GREY); shoppablePlacement.setLearnMoreText("Buy"); shoppablePlacement.setLearnMoreButtonBackground(Color.GREEN); shoppablePlacement.setLearnMoreButtonCountour(Color.BLUE); try { ShoppablePlacement placement = ((ShoppablePlacement) Controller.getInstance().getPlacement(placementId)); View shoppableAdView = placement.getShoppableAdView(context, requestId); if (shoppableAdView != null) { ((ViewGroup) holder.itemView).addView(shoppableAdView); } else { //no ad at the moment, handle holder binding } } catch (DioSdkException e) { // error handling } }
In order to customize frame and text colors use optional setters on ShoppableVideoPlacement object as shown in example above.
Note: Shopable Video will appear in case it is loaded before RecyclerViev calls onBindViewHolder for its position. If you want Shopable Video 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 Shopable Video behavior in case of switching between fragments – call:
ad.close(); to stop the ad and release the resources associated with it. ad.leave(); to pause the video ad. ad.reenter(); to resume the video ad.