1

I'm using the Glide v4 to load my images, and my app is encountering an error:

I/Glide: Root cause (1 of 1) com.bumptech.glide.load.HttpException: Not Found
    at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.onResponse(OkHttpStreamFetcher.java:73)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

at first load this is what happen, but when I reload again the image is now appearing.

I am loading an image from my RecyclerView adapter like:

class MyRecyclerViewAdapter(private val glideApp: GlideRequests): RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder>() {
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        //... some stuff
        // Set a data
        glideApp.asBitmap()
            .load(img_url)
            .into(holder.itemView.ivImageHolder)
        // Set a data
    }
}

Any help is appreciated, Thanks.

Ajay Mehta
  • 843
  • 5
  • 14
dotGitignore
  • 1,597
  • 2
  • 15
  • 34

4 Answers4

0

Try this,

private List myUrls = ...;

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
  ImageView imageView = ((MyViewHolder) viewHolder).imageView;
  String currentUrl = myUrls.get(position);

  Glide.with(fragment)
    .load(currentUrl)
    .override(imageWidthPixels, imageHeightPixels)
    .into(imageView);
}

check this also

Chanaka Weerasinghe
  • 5,404
  • 2
  • 26
  • 39
0
Glide.with(context)
    .load(img_url)
    .asBitmap()
    .into(holder.itemView.ivImageHolder);

"context" contain the instance fo the activity or fragment which is passed on to the adapter

Pranav Ashok
  • 581
  • 1
  • 6
  • 18
0

I solved the problem by changing ImageView attribute.

Changed the android:width:"wrap_content" to android:width:"match_parent".

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Arif
  • 9
  • 2
0

Just set zoom post loading the image solved the issue

ivImageHolder.setZoom(0.99f)
Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138