content: package com.alexvasilkov.gestures.sample.ex.transitions.recycler;
  
  import android.view.ViewGroup;
  
  import androidx.annotation.NonNull;
  import androidx.viewpager.widget.ViewPager;
  
  import com.alexvasilkov.gestures.commons.RecyclePagerAdapter;
  import com.alexvasilkov.gestures.sample.base.settings.SettingsController;
  import com.alexvasilkov.gestures.sample.ex.utils.GlideHelper;
  import com.alexvasilkov.gestures.sample.ex.utils.Painting;
  import com.alexvasilkov.gestures.views.GestureImageView;
  
  class PagerAdapter extends RecyclePagerAdapter<PagerAdapter.ViewHolder> {
  
      private final ViewPager viewPager;
      private final Painting[] paintings;
      private final SettingsController settingsController;
  
      PagerAdapter(ViewPager pager, Painting[] paintings, SettingsController listener) {
          this.viewPager = pager;
          this.paintings = paintings;
          this.settingsController = listener;
      }
  
      @Override
      public int getCount() {
          return paintings.length;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(@NonNull ViewGroup container) {
          ViewHolder holder = new ViewHolder(container);
          holder.image.getController().enableScrollInViewPager(viewPager);
          return holder;
      }
  
      @Override
      public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
          settingsController.apply(holder.image);
          Painting painting = paintings[position];
          GlideHelper.loadFull(holder.image, painting.imageId, painting.thumbId);
      }
  
      static GestureImageView getImageView(RecyclePagerAdapter.ViewHolder holder) {
          return ((ViewHolder) holder).image;
      }
  
  
      static class ViewHolder extends RecyclePagerAdapter.ViewHolder {
          final GestureImageView image;
  
          ViewHolder(ViewGroup container) {
              super(new GestureImageView(container.getContext()));
              image = (GestureImageView) itemView;
          }
      }
  
  }
  