1 year ago

#296865

test-img

Ben

How to load image with Glide even if the url return a 301 status?

I'm trying to load images with Glide.

It works when url return a 200 status but sometimes the server return the image with a status 301. With 200 or 301 the image is correctly showing in the browser.

Glide doesn’t seem to like it.

How am I supposed to handle this ?

Glide.with(ctx)
    .asBitmap()
    .load(url)
    .apply(options)
    .error(imgError)
    .override(width,height)
    .transition(BitmapTransitionOptions.withCrossFade(GLIDE_TIME_TRANSITION))
    .addListener(object : RequestListener<Bitmap> {
        override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
            // WHAT TO DO HERE ?
            return false
        }

        override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {               
            return false
        }

    })
    .into(this)

I think I have to do something in onLoadFailed but I'm not sure and I dont know how to achieve it...

Thank's for your help.

android

image

android-glide

0 Answers

Your Answer

Accepted video resources