title: RecyclearView + Glide + Scroll : Load images taking too long or not loading
body: <p>I am using Glide Image Loader.
  it takes too long (more than 200 seconds)to load image from server
   and in some cases do not load. 
  All images are stored on Cloud server.</p>
  
  <p>When I scroll back to the top the image is displayed like first time and it takes a little time to be displayed ,Image Caching is also not working properly
  In Application like Amazon,Facebook one time loaded image is not disappears . I want same technique on my application.</p>
  
  <blockquote>
    <p>I am using Staggered Gridview using DynamicheightImageview,For that I am calling AsyncTask on onBindViewHolder</p>
  </blockquote>
  
  <pre><code>   new GetImageTask(singleArtDataitem, vh.imageView, position).execute(singleArtDataitem);
  </code></pre>
  
  <p><strong>AsyncTask</strong></p>
  
  <pre><code>     private class GetImageTask extends AsyncTask&lt;SingleArtData, Void, Float&gt; {
  
  
          private SingleArtData item;
          private final DynamicHeightImageView imageView;
          int position;
  
          public GetImageTask(SingleArtData item, DynamicHeightImageView holder, int position) {
              this.imageView = holder;
              this.position = position;
          }
  
          @Override
          protected Float doInBackground(SingleArtData... params) {
              item = params[0];
               try {
  
                  if (GlobalMethods.isNotEmpty(item.getImageName())) {
                      item.setImagefullurl(baseuri + item.getImageName());
                      URL neturl = new URL(item.getImagefullurl());
                      final Bitmap image = BitmapFactory.decodeStream(neturl.openConnection().getInputStream());
                      int width = image.getWidth();
                      int height = image.getHeight();
                      item.setImage_width(width);
                      item.setImage_height(height);
                      float ratio = (float) height / (float) width;
                      item.setImage_ratio(ratio);
                  } else {
                      item.setImagefullurl(null);
                  }
              } catch (Exception e) {
  
                  item.setImagefullurl(null);
                  e.printStackTrace();
              }
              return item.getImage_ratio();
          }
  
          @Override
          protected void onPostExecute(Float result) {
  
              RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
              rlp.height = (int) (rlp.width * result);
              imageView.setLayoutParams(rlp);
              imageView.setHeightRatio(result);
  
              if (GlobalMethods.isNotEmpty(item.getImagefullurl())) {
  //                Picasso.with(mContext)
  //                        .load(baseuri + item.getImageName()).placeholder(PlaceHolderDrawableHelper.getBackgroundDrawable(position))
  //                        .error(R.drawable.ic_med)
  //                        .into(imageView);
                  Glide.with(MyApplication.getInstance())
                          .load(item.getImagefullurl()).placeholder(PlaceHolderDrawableHelper.getBackgroundDrawable(position))
                          .error(R.drawable.loadicon)
                          .placeholder(PlaceHolderDrawableHelper.getBackgroundDrawable(position))
                          .diskCacheStrategy(DiskCacheStrategy.ALL)
                          .skipMemoryCache(false)
                          .into(imageView);
              }
  
  
          }
  
  
      }
  </code></pre>
  
  <p>Thanks in advance.</p>