private void renderViewPager() {
    // Use view pager
    carouselViewPager = new SdkCenteredViewPager(getContext());
    carouselViewPager.setFocusable(false);
    carouselViewPager.setFocusableInTouchMode(false);
    carouselViewPager.setLayoutParams(
        LayoutUtils.createLinearParams(
            LayoutUtils.MATCH_PARENT, LayoutUtils.MATCH_PARENT, Gravity.CENTER));
    carouselViewPager.setBackgroundColor(AppLovinCarouselViewSettings.VIEW_PAGER_BACKGROUND_COLOR);
    carouselViewPager.setPageMargin(AppLovinCarouselViewSettings.VIEW_PAGER_MARGIN);
    carouselViewPager.setOffscreenPageLimit(
        AppLovinCarouselViewSettings.VIEW_PAGER_OFF_SCREEN_PAGE_LIMIT);

    carouselViewPager.setClipToPadding(false);

    adapter = new InlineCarouselAdapter(getContext(), sdk, this);

    carouselViewPager.setAdapter(this.adapter);

    carouselViewPager.setOnPageChangeListener(
        new SdkCenteredViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // Useless for us.
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            if (state == SdkCenteredViewPager.SCROLL_STATE_IDLE) {
              final int currentItem = carouselViewPager.getCurrentItem();
              lastActiveCardIndex = currentItem;

              // Activate the current card if it exists (which it should always)
              activateCard(currentItem);

              // Deactivate the left card if it exists
              deactivateCard(currentItem - 1);

              // Deactivate the right card if it exists
              deactivateCard(currentItem + 1);
            }
          }

          @Override
          public void onPageSelected(int position) {
            // Useless, invoked when .setPage(int) is called
          }
        });

    addView(carouselViewPager);
    removeLoadingIndicator();
  }
  @Override
  public void onResume(Activity activity) {
    if (parentActivity == null) {
      parentActivity = activity;
    }

    if (wasPaused) {
      renderActivityIndicator();

      renderCarousel();

      if (carouselViewPager != null) {
        carouselViewPager.setCurrentItem(lastActiveCardIndex);
        activateCard(carouselViewPager.getCurrentItem());
      }
    }
  }
  /**
   * Intercept touch events which are consumed later by the video view and forward them to the view
   * pager. This is a workaround for an Android limitation: OnClickListeners on the video views
   * absorb touch events and prevent events from propagating up. By intercepting here & manually
   * dispatching, the view pager still receives drag events even if the video views consume click
   * events.
   */
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (carouselViewPager != null) {
      carouselViewPager.onTouchEvent(ev);
    }

    return false;
  }