title: OnPageChangeListener in ViewPager adapter?
body: <p>I have a regular ViewPager with an adapter:</p>
  
  <pre><code>public class MyDialogFragment extends DialogFragment {
  
      private ViewPager viewPager;
  
      private MyViewPagerAdapter myViewPagerAdapter;
  
      private City city;
  
      public static MyDialogFragment newInstance() {
          MyDialogFragment fragment = new MyDialogFragment();
  
          return fragment;
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment_layout, container, false);
  
          viewPager = (ViewPager) v.findViewById(R.id.viewPager);
  
          city = Parcels.unwrap(getArguments().getParcelable("city"));
  
          myViewPagerAdapter = new MyViewPagerAdapter(getContext());
          viewPager.setAdapter(myViewPagerAdapter);
  
          viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
              @Override
              public void onPageSelected(int position) {
                  // Page changed
              }
          });
  
          return v;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      public class MyViewPagerAdapter extends PagerAdapter {
  
          private Context context;
  
          private LayoutInflater layoutInflater;
  
          public MyViewPagerAdapter(Context context) {
              this.context = context;
          }
  
          @Override
          public Object instantiateItem(ViewGroup container, int position) {
              layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              View view = layoutInflater.inflate(R.layout.city_layout, container, false);
  
              ImageView imageView = (ImageView) view.findViewById(R.id.cityImage);
  
              Glide.with(context)
                      .load(city.getImage())
                      .into(imageView);
              }
  
              container.addView(view);
  
              return view;
          }
  
          @Override
          public int getCount() {
              return city.size();
          }
  
          @Override
          public boolean isViewFromObject(View view, Object obj) {
              return view == ((View) obj);
          }
  
          @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
              container.removeView((View) object);
          }
      }
  }
  </code></pre>
  
  <p>As you can see, I have a page change listener set on my <code>ViewPager</code>. But I need to be able to notify the <strong>adapter</strong> when the page has changed so that I can modify the adapter's  <code>ImageView</code>. How can I do this?</p>