Universal Image Loader images with big resolution - android

I using universal image loader to load images from gallery to listView and i have a problem with big images when scrolling images with bigger resolution loads slower than images with lower resolution i quess it should be like that but is there any way to load them in same speed?
options = new DisplayImageOptions.Builder()
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
.resetViewBeforeLoading(false)
.cacheInMemory(false)
.cacheOnDisk(false)
.build();``
code above doesnt fix this problem.

Try to preload those images which need to be shown in the next listView's items.

Related

Downloaded images are showing wrong orientation using the Android universal image loader

I used the android universal image loader to download the image
If I download the iOS uploaded image then it's showing 270 degree orientation.
If downloaded the s7 edge uploaded images showing 90 degree orientation
If I downloaded the Nexus mobile uploaded images are showing correct orientation
This is code I used to download the images
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.build();
ImageLoader.getInstance().init(config);
options = new DisplayImageOptions.Builder().cacheInMemory(true)
.cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY).build();
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(url, image, options);
please advise to overcome from this issue
first set cacheOnDisk(false) because, It will show the previous image after you changed the code.
then changed it like this
options = new DisplayImageOptions.Builder().cacheInMemory(true)
.considerExifParams(true)
.cacheOnDisk(true).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build();
This is solved my issue.
For Image Handling I highly recommend using Picasso Library. (http://square.github.io/picasso/). You can follow their samples on GitHub if you want to learn more about it.
It automatically handles Image Scaling and other issues related to image downloading and parsing like OutOfMemory, etc.
Basic Image loading from URL can be done like this :
Picasso.with(context)
.load(url)
.placeholder(R.drawable.user_placeholder)
.error(R.drawable.user_placeholder_error)
.into(imageView);

UIL, Picasso - Images in adapter always reload when stop scrolling

I have ListView with text and large image from internet. My image item has fit width and wrap_content height.
I tried to display image in background with UIL & Picasso. Both of them can work but the image always reloads when I stop scrolling, and it makes ListView flickering
It looks like this:
You can see that it reload downloaded and cached images when I stop scrolling (I scroll down and then scroll up).
How can I prevent this happen?
<ImageView android:id="#+id/imgFeed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>
// UIL
options = new DisplayImageOptions.Builder()
.showImageOnLoading(defaultImage)
.showImageOnFail(defaultImage)
.showImageForEmptyUri(defaultImage)
.resetViewBeforeLoading(false)
.cacheOnDisk(true).delayBeforeLoading(0)
.displayer(new FadeInBitmapDisplayer(200)).cacheInMemory(true).imageScaleType(ImageScaleType.EXACTLY_STRETCHED).build();
ImageAware imageAware = new ImageViewAware(viewHolder.imgFeed, false);
ImageLoader.getInstance().displayImage(item.getPhotoUrl(), imageAware, options);
// Picasso
Picasso.with(getContext())
.load(item.getPhotoUrl())
.placeholder(R.drawable.place_holder_big)
.resize(screenWidth, 0) //set max width
.into(viewHolder.imgFeed);
For UIL, I tried many ways in this issue but they don't work for me at all.
Update: seems I faced with memory cache issue like this question. But how can I fix this issue? Look at Facebook app, they did it very well. All images have different sizes with fit width, and very smooth scrolling without reloading images. How can they do that?
If you're wondering how Facebook did it, they actually released their image loading library (https://github.com/facebook/fresco)
Is it possible you are actually calling notifyDataSetChanged on the underlying ListView at that time? Also are you using hasStableIds()?
For UIL you could try using a WeakMemoryCache (refer to https://github.com/nostra13/Android-Universal-Image-Loader/wiki/Useful-Info) as that'll theoretically allow you to make use of all available memory though it may cause a lot of extra GC calls.
For Picasso Taha's method looks like your best bet!
Maybe your memory cache size is small and Picasso tries to load images from disc cache. Please check here for deciding cache size. You can try to increase cache size of Picasso by:
Picasso p = new Picasso.Builder(context)
.memoryCache(new LruCache(cacheSize))
.build();
However in my opinion your app looks like having an endless feed. Which means your memory cache will be full at some time and you'll have to use disc cache. Retrieving data from the disc cache is slower compared to memory cache.

Load multiple images in ImageView

I have a grid view which shows some images loaded from a server. I use Universal image loader to load the images in the imageView. the problem is it takes time to load those images and I don't want their places to be empty. I want to show an image which is located in the assets of the app and then load the images from server on top of it.
I wanted to ask if you have any solutions to this problem.Thanks very much
Very generic way to use DisplayImageOptions is as
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.placeholder_image).showImageForEmptyUri(0)
.resetViewBeforeLoading(true).cacheInMemory(true).cacheOnDisk(true)
.imageScaleType(ImageScaleType.IN_SAMPLE_INT).bitmapConfig(Bitmap.Config.RGB_565)
.delayBeforeLoading(100).displayer(new FadeInBitmapDisplayer(500)).build();
Here showImageOnLoading(R.drawable.placeholder_image) method is used to display a placeholder image until the real image is loaded. R.drawable.placeholder_image is the drawable you want to show as placeholder.

Load large images from URL using Picasso

I load about images from about 30 different URLs into a ListView using Picasso. Some of the images are small, some of them are quite large (>3MB).
When I think of reducing the images using the Picasso method .resize(width, height) I dont know the original ration of the image I downloaded.
How could I possible know the dimensions of the downloaded (original) image in order to set the "new dimensions" or the resized image in the correct/appropriate relation?
Thanks

How to reduce image quality when using Universal Image Loader?

I'm using Universal Image Loader and I have to load 17 images from this page http://www.mangareader.net/detective-conan/898 then display it into ViewPager. However, images load very slow so I want to reduce the image quality and size for performance. What should I do to improve the speed?
Thanks.
I think it is not posible to download a scaled down version of image if the server does not supprt that feature. You can read more about it here.
One soltion to this is you can cache images when you run it for the first time. And next time check if the image is available in cache or not. if it is present in cache, get it from device else download it and cache it.
use BitmapConfigARGB_4444
DisplayImageOptions profilepicOptions = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.user_pic).cacheInMemory()
.cacheOnDisc().bitmapConfig(Bitmap.Config.ARGB_4444).build();

Categories

Resources