I am working with Android Picasso Library and after setting image from drawable folder in placeholder,I am getting outOfMemory exception. Do picasso place holder image stays in memory, If yes then how to remove placeHolder image when actual image is loaded?
This happens because system try to Scale it according to density of the device .The solution worked for me is to create a folder named drawable-nodpi inside your res folder . Then put your placeholder image into that folder .
Let me know if it works .
You may try resizing your placeholder image since it might be to big and causing OutOfMemory, but it can be also more complex error not only of placeholder. And maybe it's not the problem of placeholder but of current image loaded from url which is too big? You can resize this image with below code:
picasso.with(mContext)
.load(someUrl)
.resize(sizeX, sizeY)
.placeHolder(R.drawable.placeholder)
.into(imageView);
Related
My Android application need load amounts image from Internet with api,those pictures so big and massive that need more Lots of bandwidth,So I want load partial(compress) image to save bandwidth.
At first,I tried to use the 'thumbnail' of Glide,it was seem work,the image is compressed but it load full image final.
Then,I tried to use the 'override' of Glide,but it only resized the picture in ImageView,The full image is downloaded too.
//The Thumbnail() can load the partial image at first,but download full picture final
Glide.with(mContext).load(item.imgUrl).thumbnail( 0.5f )
.apply(bitmapTransform(new RoundedCornersTransformation(50, 0)))
.into(myViewHolder.commodityImage);
//The override() can resize the picture inside ImageView,but it download the full picture too!
Glide.with(mContext).load(item.imgUrl)
.apply(bitmapTransform(new RoundedCornersTransformation(50, 0)).override(400,400))
.into(myViewHolder.commodityImage);
So,is there a way to download the image partially like the Glide thumbnial but do not download full picture.
Try to used this..
Glide.with(imageView)
.load(path)
.apply(RequestOptions().placeholder(R.drawable.place_holder).override(500, Target.SIZE_ORIGINAL))
.into(imageView)
I am trying to load images (around 5mb each) into ImageView's of size 45x45 dp in a RecyclerView. Even though original image is large, doesn't Glide load a smaller version of it because target ImageView is small? So, I expect Glide to load images in just a few seconds with an average internet speed. But, it takes like 20 seconds. What is the problem?
Images are stored in firebase storage.
Glide code :
Glide.with(context).load(firebaseStorageUrl).into(imageView);
Glide needs to load the full image from the internet before it can resize it. So the download takes a long time the first time. Afterwards it can use the small image from the cahe it created if you have caching activated.
In case you don't want to load smaller files, I recommend using a Gif-drawable library for loading large images from Glide into GifDrawable(works as an ImageView).
It can load files more than 100MB very fast. It works with plain JPG, PNG and BMP too. If these are GIFs, it plays without any delay or freeze.
If drawables declared by android:src and/or android:background are GIF files then they will be automatically recognized as GifDrawables and animated. If given drawable is not a GIF then mentioned Views work like plain ImageView and ImageButton.
Glide downloads the image first, and then you have methods to retrieve the image as bitmap to resize and compress the image. However, that won't solve your problem . Possibly there are two solutions for this:
Keep a low sized image in the server.
Use a File downloader library, which helps to download images serially and asynchronously as a queue, which would help to download the file quick. FileDownloader library is a good option for this.
Use Override in Glide for load image faster.
I want to load multiple drawable-resources in RecyclerView and i am using Picasso in RecyclerView.ViewHolder for this task.
Picasso.with(context)
.load(imageList.get(position))
.into(imageView);
Picasso loads the drawable-resources which are in drawable folder but it doesn't load resources from other drawable.
For example if i put the drawables in all drawable folders(mdpi,hdpi,xhdpi etc) except "drawable" folder, It doesn't work.
So is there something I am missing? is it possible to dynamic reference to the drawables using Picasso?
Picasso should load mipmaps. Try forcing just one to show, like
Picasso.with(context).load(R.mipmap.ic_launcher).into(imageView);
and see if is loading. If it is, there is something with your id's from array.
i am using Glide or Picasso for loading the image like
Glide.with(context).load(POST_IMAGE).placeholder(R.drawable.loading_img).error(R.drawable.bg_480_800).into(image);
Picasso.with(context).load("image url").error(R.drawable.bg_480_800).placeholder(R.drawable.loading_img).into(holder.imageURL);
In these two, i'm using image as place holder from the drawable folder. Now i want to use text inside the place holder instead of image from drawable folder.
So, please help me to load text instead of loading image from the drawable folder
Placeholder is a Drawable, so what you'll need is some kind of Drawable that is able to display text. This library does exactly that, and does it pretty well.
I'm trying to load an image from filesystem into an imageView with the ion library.
When I'm using the following code:
Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.load(uri);
it (sometimes) results in a kind of blurry image.
When not using ion like the following the pictures appear sharply:
imageView.setImageBitmap(BitmapFactory.decodeFile(uri.toString()));
Is there a standard compression coming with ion that I can disable?
Strangely not every picture is blurry when using ion, e.g. I have two identical images, only with another name. When I load them into the imageView with ion one is blurry, one is not.
Any help or tips are appreciated!
Ion tries to load the image to fit the bounds of the ImageView. So make sure your ImageView is sized properly in your layout. Alternatively, if you use adjustViewBounds=true to indicate the ImageView is adjusted by the image contents, it won't do that. Or alternatively smartsize(false).
Try this,
Ion.with(context)
.load(url)
.withBitmap()
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.intoImageView(imageView);