Picasso setting placeholder image but not the actual image - android

I am using the Picasso library on android to display profile images, but the image does not load for some reason and the app only displays the placeholder image.
Picasso.get()
.load(R.drawable.ic_person_black_100dp)
.placeholder(R.drawable.common_full_open_on_phone)
.into(profileImageView);

Picasso 2.X doesn't support vector drawable. You can either use Glide or use a workaround:
Glide.with(context)
.load(R.drawable.my_vector_drawable)
.into(mImageView);
When load() call fails, the error handling mechanism of Picasso seems to work with vector drawables:
Picasso.get()
.load(R.drawable.my_vector_drawable)
.error(R.drawable.my_vector_drawable)
.into(mImageView);

Related

How to display images in circular transform using glide v4 in android

How to display an image in circular transform in android using glide v4.
I am trying to display the image in circular transform in an image view using glide v4 in android using the following code
RequestOptions options=new RequestOptions();
Glide.with(this).load(urlProfileImg)
.apply(RequestOptions.circleCropTransform())
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imgProfile);
I am not sure whether to use this or context
If I have to use context, someone please suggest me how to get the context and how to make the images displayed in circular form using glide v4 in android

jpeg image format not supported by picasso or glide

Picasso and Glide aren't supporting/loading image URL with .jpeg extension within image view.
I am working in grid view where image is being loaded in image view , either by picasso or by glide but it isn't supporting the URL with .jpeg extension.
Are there any alternates available?
Glide.with(getActivity())
.load("https://abc/profile.jpeg")
.centerCrop()
.placeholder(logo)
.into(imageView);
Picasso.get()
.load("https://abc/profile.jpeg")
.placeholder(R.drawable.logo)
.error(R.drawable.logo)
.into(imageView);
Change the extension of images to .jpg and it'll work.

Loading image in android imageview

How to load images in same image view from web or local android gallery?
I have an image view which has three options for loading images templates from web service,from gallery, from camera.I am using Glide library to load images from web service, Now, if i load image from web by glide and remove that image by remove button which i have for removing a picture after i pick image from gallery it doesn't load the image from gallery instead load the same image from glide which i removed before.
write the code like this for loading image .
Glide.with(mContext).load(imgUrl)
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
Glide Library Intoduction Go through with this link, hope it will be work
You can use Picasso library. Image loading using Picasso is very easy, you can do it like this way
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
and in their website you can get every details.
and another Library is Glide. You can use Glide too for loading image..
You can also use Glide:
Glide.with(context).load(image).asBitmap().placeholder(R.drawable.placeholder).error(R.drawable.error).into(imageview);

Out of Memory issue in a gallery like application

I am trying to create an application which contains lots of Images from web services.I am using Picasso library for loading images into a gallery like fragment with RecyclerView having lazy load and passing list of URL's to slider activity with ViewPager i am dealing lot of images so after few slides it starts throwing Out of Memory(OOM) exception.I have tried with Glide its is stretching the image so i stick with Picasso.Tried a lot of methods like using large heap and allowing hardware access.Any method to identify and handle this issue would be helpful.
Picasso.with(context)
.load(image.getImageURL())
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.skipMemoryCache()
.placeholder(R.drawable.poster_default)
.error(R.drawable.poster_default)
.into(mImageView);
Agree with previous answer. You can also try use RGB_565 config. The image with this config two times smaller
Picasso picasso = new Picasso.Builder(this)
.defaultBitmapConfig(Bitmap.Config.RGB_565)
.build();
And set this instance to picasso
Picasso.setSingletonInstance(picasso);
The code snippet should be placed in onCreate method in android.app.Application class
Android uses bitmaps for images so that would mean adding large images will consume tons of memory. What I do in my projects is add fit() to the Picasso call to it so it will resize the image for me instead of loading it full size in memory.
Try something like below and see if it's fixed
Picasso.with(context)
.load(image.getImageURL())
.fit()
.centerCrop()
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.skipMemoryCache()
.placeholder(R.drawable.poster_default)
.error(R.drawable.poster_default)
.into(mImageView);

Is there any way to use placeholder or error drawables with remote views using Picasso,Glide or any

I am not able to give any placeholder or error drawable in remoteview using Picasso.
Picasso
.with(context)
.load(imageurl)
.into(remoteview,R.id.icon,NOTIFICATION_ID,notification);
Even used this it is giving me error
Picasso
.with(context)
.load(imageurl)
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.error)
.into(remoteview,R.id.icon,NOTIFICATION_ID,notification);
(Cannot use placeholder or error drawables with remote views.)
What should i do ?
You can set placeholder via xml android:src="drawable/myimage" jitinsharma suggested, and for error image inside error picass callback change it with another drawable resource: imageView.setImageResource(R.drawable.myErrorImage);
Is that solve your problem?
p.s. still interesting for me, why Picasso can't work with remote views.

Categories

Resources