content: package id.merahmuda.bcd.adapter;
  
  import android.content.Context;
  import android.os.Parcelable;
  import android.support.v4.view.PagerAdapter;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  
  import java.util.ArrayList;
  
  import id.merahmuda.bcd.R;
  import id.merahmuda.bcd.helper.ImageSlider;
  
  /**
   * Created by Ujang Wahyu on 12,September,2018
   */
  
  public class SlidingImageAdapter extends PagerAdapter {
  
  
      private ArrayList<ImageSlider> imageModelArrayList;
      private LayoutInflater inflater;
      private Context context;
  
  
      public SlidingImageAdapter(Context context, ArrayList<ImageSlider> imageModelArrayList) {
          this.context = context;
          this.imageModelArrayList = imageModelArrayList;
          inflater = LayoutInflater.from(context);
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          container.removeView((View) object);
      }
  
      @Override
      public int getCount() {
          return imageModelArrayList.size();
      }
  
      @Override
      public Object instantiateItem(ViewGroup view, int position) {
          View imageLayout = inflater.inflate(R.layout.slidingimages_layout, view, false);
  
          assert imageLayout != null;
          final ImageView imageView = (ImageView) imageLayout
                  .findViewById(R.id.image);
  
  
          imageView.setImageResource(imageModelArrayList.get(position).getImage_drawable());
  
          view.addView(imageLayout, 0);
  
          return imageLayout;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view.equals(object);
      }
  
      @Override
      public void restoreState(Parcelable state, ClassLoader loader) {
      }
  
      @Override
      public Parcelable saveState() {
          return null;
      }
  
  
  }
  