I use Glide library in my Android project to update avatar from URL that comes in response from API.
The problem is that when I try to load different image (from different URL) to the same imageView it shows me an image that was downloaded first time. (URL forming works fine, I tried it in browser and it shows the needed image)
Here is my code:
EditProfileFragment.xml
public static final String IMAGE_BASE_URL = "http://myapi.com/img/";
String imageUrl = Const.IMAGE_BASE_URL + cb_getProfile.photo; //imageName.jpg
Glide.with(mContext)
.load(imageUrl)
.animate(R.anim.abc_fade_in)
.centerCrop()
.into(mImageView_photo);
Solved this problem by adding a StringSignature when loading image from the URL.
Source
Glide.with(mContext)
.load(imageUrl)
.animate(R.anim.abc_fade_in)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.centerCrop()
.into(mImageView_photo)
;
Thanks to Yoav Sternberg.
Related
In my application, I was trying to get the thumbnail of a book from google play books API and display it in an image view but somehow what I did is not working.
Glide.with(holder.thumb.getContext())
.load(curThumb)
.into(holder.thumb);
when I used the above method with a local image it worked also thumbnail URL is correct
I tried using Glide v4.0.0-RC1 use RequestOptions to add the placeholder, error image and other options make sure URL(image_url) starts with https, not with HTTP
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.mipmap.ic_launcher_round)
.error(R.drawable.your_error_image);
RequestOptions to add placeholder, error image and to customize image
Glide.with(this).load(image_url).apply(options).into(imageView);
This question already has answers here:
How to get URL from Firebase Storage getDownloadURL
(13 answers)
Closed 4 years ago.
So when I upload an image onto Firebase Storage, the getDownloadUrl() method generates a string such as: com.google.android.gms.tasks.zzu#275cc4
Now I'm trying to place the image uploaded into an ImageView:
ImageView img;
img = v.findViewById(R.id.imgView);
Glide.with(getApplicationContext()).load("com.google.android.gms.tasks.zzu#275cc4").into(img);
This doesn't seem to load the image. I tried with the full firebase url https://firebasestorage.googleapis.com/v0/..... and this worked, but I can't seem to find a method that generates this when I upload an image?
storageRef.child(path).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
#Override
public void onSuccess(Uri uri) {
Glide.with(getApplicationContext()).load(uri.toString()).into(img);
}
});
Hope this will help you.......Have a nice day
To solve this, you need to pass to the load() method the actual url of the photo. I'm affraid:
com.google.android.gms.tasks.zzu#275cc4
Is not a valid url for an image. So change the above url with one that is correct formated and includes: https://firebasestorage.googleapis.com/v0/....
To verify if the url is correct, just copy and paste that url in a browser and see if it opens an image. If it doesn't open, it means that you have provided an incorrect url.
I'm using Glide to load images in image view from URLs.
If the image is not available in the server and URL doesn't exit/pointing a deleted file then the image view becomes blank..
How to know if URL has a image or not?
//do magic here if/else
Glide
.with(context)
.load(url)
.centerCrop()
.into(myImageView);
Thanks a lot in advance...
Use placeholder() or error() if your objective is to show some local image if the URL does not point to a valid image.
Use RequestListener if you want to learn about failures more generally.
Try out this way.
Glide.with(passContext)
.applyDefaultRequestOptions(
new RequestOptions()
.placeholder(R.drawable.ic_user_default)
.error(R.drawable.ic_user_default)
)
.load(url)
.into(imageview);
I have an image in my #drawable/myimage.jpg of which I would like to load on my ImageView through Glide. Glide however, only accepts Uri's to load the actual image to the ImageView.
Here's the code:
uriImage = Uri.parse("#drawable/myimage.jpg");
//LOADS IMAGES USING GLIDE
Glide.with(AboutActivity.this).load(uriImage).into(imgView);
It somewhat doesn't work. Is there any work-arounds this?
Sorry for being naive, I just started using Android Studio again :)
try this code:
String imageUrl = getURLForResource(R.drawable.personIcon);
// Load image
Glide.with(patientProfileImageView.getContext())
.load(imageUrl)
.into(patientProfileImageView);
it helps you
Simply do this!
Glide.with(AboutActivity.this).load(R.drawable.resouce_name).into(imgView);
Usually we loading picture is on FragmentPagerAdapter.getItem method.
such as:
Picasso.with(context)
.load(url)
.placeholder(R.drawable.user_placeholder)
.error(R.drawable.user_placeholder_error).into(imageView);
Images then don't show in ViewPager probably never download. But, I want to pre-download images. I've used Picasso.with().load(url).downloadOnly, but this causes multiple unnecessary same url downloading.
I want to pre-download images. If have same url image downloading, it merge downloading interface.
I'm using Glide.It's effective and power.Preload image only use preload() method.