Reputation: 11
I am using the Picasso
library to set the image from URL. This URL is working in other programming language but not in Android.
Picasso.with(context).load(product_modal.getImage()).placeholder(R.drawable.ic_no_image).into(holder.iv_thumbnail_filled);
Upvotes: 0
Views: 3330
Reputation: 175
If you have HTTP 504 error, have a try: Uninstalling the app and installing it again!
Info from here.
Upvotes: 0
Reputation: 7669
Finally, I found the actual problem that you have faced. Replace https
to http
in your URL. Because your site does not have SSL.
Just created a method for loading image
private void loadImage(final ImageView imageView, final String imageUrl){
Picasso.get()
.load(imageUrl)
.placeholder(R.drawable.image_white)
.into(imageView , new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
String updatedImageUrl;
if (imageUrl.contains("https")){
updatedImageUrl = imageUrl.replace("https", "http");
}else{
updatedImageUrl = imageUrl.replace("http", "https");
}
loadImage(imageView, updatedImageUrl);
}
});
}
You just need to provide an imageView
and the image URL. For the first time if image not loaded then its try to replace https
to http
and then try load the image.
Using the method by using this:
loadImage(holder.iv_thumbnail_filled, product_modal.getImage());
And make sure you have Internet Access Permission on AndroidMenifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
Hope this will solve your problem.
Upvotes: 1