title: Images loading randomly into view pager with Glide and SimpleTarget
body: <p>I'm using <code>Glide</code> to load image into a <code>ViewPager</code> using an <code>PagerAdapter</code>.
  When I load the images using the following method:</p>
  
  <pre><code>Glide.with(mContext).load(mImage).placeholder(R.drawable.placeholder).into(mImageView);
  </code></pre>
  
  <p>Everything works fine, but now I need to get the bitmap from glide and store it in a map when it loads for future edit, so I switched this method to the following one:</p>
  
  <pre><code>Glide.with(mContext).load(mImage).asBitmap().placeholder(R.drawable.placeholder).into(new SimpleTarget&lt;Bitmap&gt;() {
  
                  @Override
                  public void onLoadStarted(Drawable placeholder) {
                      super.onLoadStarted(placeholder);
                      mImageView.setImageDrawable(placeholder);
                  }
  
                  @Override
                  public void onResourceReady(Bitmap bitmap, GlideAnimation&lt;? super Bitmap&gt; glideAnimation) {
                      if (bitmap != null) {
                          mImageView.setImageBitmap(bitmap);
                      }
                      mBitmapMap.put(position, bitmap);
                      mInterface.onImageLoaded(position, bitmap);
                  }
              });
  </code></pre>
  
  <p>But the result is that the image not always shown. I think it's some how related to the fact the glide loads images async and at some point it returns when <code>instatiateItem</code> method already finished running.</p>
  
  <p>It looks like <a href="https://stackoverflow.com/questions/7263291/viewpager-pageradapter-not-updating-the-view">this question</a> is related. But the suggestions there did not help me. Has someone encountered this problem and has a solution for it?</p>