I'm loading an image from a url like this. If the image is taking a really long time to load, I want to load another image in its place so I used .error() to load an error image if the load fails, but this fail never gets called. Instead, the original image will eventually load after a long time, but I don't want to wait this long for the image to load. I tried using .timeout() but that doesn't do anything.
Glide.with(this)
.load(url)
.error(Glide.with(errorUrl).load(imageView))
.into(imageView);
CodePudding user response:
You can use placeholder attribute of Glide. Inser your placeholder image inside drawable folder. And use it like this.
Glide.with(this)
.load(url)
.placeholder(R.id.your drawable name)
.error(errorUrl)
.into(imageView)
CodePudding user response:
Glide.with(context)
.load(url)
.placeholder(R.id.your drawable name) //this will be shown until actul image load
.apply(new RequestOptions().override(150, 150)) //for resizing orgininal image
.into(imageView);
Note: Lower resolution in override(150, 150)
would result in faster loading so choose accordingly.