0

I'm using Glide to load an image from an API. I am using a gif to show loading before the image loads so initially I used specific 250dp of height of imageview and once the image loads properly, I'm setting the height as WRAP_CONTENT and scaletype of FIT_XY inside onResourceReady of glide listener. But here, sometimes image loads with its full height and other times when I scroll up it again loads the same image in same imageview with compressed height, it seems onResourceReady is getting executed the not all the times. `Glide.with(context)

      .load(outerHits.getHits().get(position).get_source().getProfilePic())
                .thumbnail(Glide.with(context).load(R.drawable.loading_gif3))
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                        ((ViewHolder6) holder).card_gallary1_img1.setLayoutParams(params);
                        ((ViewHolder6) holder).card_gallary1_img1.setScaleType(ImageView.ScaleType.FIT_XY);
                        return false;
                    }
                })
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .into(((ViewHolder6) holder).card_gallary1_img1);`

Xml is

<ImageView
    android:id="@+id/card_gallary1_img1"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:background="@color/white"
    android:src="@drawable/no_image"/>
Abhishek Kumar
  • 4,532
  • 5
  • 31
  • 53
  • Possible duplicate of [Glide listener doesn't work](https://stackoverflow.com/questions/32503327/glide-listener-doesnt-work) – ADM Jan 17 '18 at 07:28
  • I have gone through https://stackoverflow.com/questions/32503327/glide-listener-doesnt-work but it doesn't solve my problem as I already have returned false in both my callback methods. – Abhishek Kumar Jan 17 '18 at 07:54
  • How will returning solves this problem while you said the callback not getting called. Have you looked into [This issue](https://github.com/bumptech/glide/issues/618). – ADM Jan 17 '18 at 07:57
  • do you manually remove callback from ImageView on viewHolder detach ? – JiratPasuksmit Jan 17 '18 at 08:10

0 Answers0