Im using Universal Image Loader and works well in my app, however i need get the app icons and shorcuts bitmaps, And As far that i know can't get this using UIL, so i use package manager or other resource to load the bitmaps, so my problem is if ican use any option to "push" into UIL the bitmap and then "pull" this bitmap if its available i can use
MemoryCacheUtil.findCachedBitmapsForImageUri(imageUri, ImageLoader.getInstance().getMemoryCache());
Whith this code i can get the cached bitmap but its possible "save" the image using UIL?
Related
I need to display a list of images in my application, and i get those images from an API call as an URL. Now I'm using Glide to show them, but i don't like the loading effect it makes (blank space while loading, and the the image). Is there any way to instant show those images, without any loading time and possibly without downloading them?
Since the images are stored on a remote server there is no way to bypass the downloading process, however Glide makes sure to only download the image from remote server when necessary, as the docs state
By default, Glide checks multiple layers of caches before starting a
new request for an image:
Active resources - Is this image displayed in another View right now?
Memory cache - Was this image recently loaded and still in memory?
Resource - Has this image been decoded, transformed, and written to
the disk cache before? Data - Was the data this image was obtained
from written to the disk cache before? The first two steps check to
see if the resource is in memory and if so, return the image
immediately. The second two steps check to see if the image is on disk
and return quickly, but asynchronously.
If all four steps fail to find the image, then Glide will go back to
the original source to retrieve the data (the original File, Uri, Url
etc).
To resolve this,
but i don't like the loading effect it makes (blank space while
loading, and the the image)
You can instead add a default placeholder on the ImageView until the real image is downloaded. This will display a default image while your actual image is downloading and then after download completion will replace it with the actual one.
Glide
.with(context)
.load(url)
.placeholder(R.drawable.ic_placeholder) //your default placeholder resource
.into(imageView)
you can display images from url by two ways:
Without any third party library:
URL url = new URL("URL of image here");
Bitmap bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bitmap);
Second way is by using Picasso
I have looked at Glide and understand that Glide doesn't take Bitmap (or a Future of Bitmap) parameter in load function.
My current approach is to fall back to manual way following the blog here. Multithreading For Performance, just replacing the download function to create the bitmap in real time.
I wonder is there any image libraries could handle this task? Thanks.
UPDATE:
Or I can actually save the Bitmap in advanced then only pass the file name to Glide. it loads the image the normal way. In this situation, I need to house-keep the cache file.
So, the thing is that I am fetching some images using Glide. I fetch them directly into bitmap, and then I blur that bitmap using RenderScript and than show on UI blurred one.
UI itself has "All Images" activity and "Single Image" activity. User clicks on the image on the first activity, and the blurred version is showed on the second one, so it is possible to go back and forth opening and closing the same image.
The issue is that this cause image to become broken, and there is no way to fix it unless you clear all app data.
The issue even survives app reinstall (using Android Studio). So, if I open image, and it is displayed as it should, than make some changes in code, and install the app again, image would show broken immediately after
installation, unless I clear data.
It happens only with bitmaps loaded using glide. If I get some drawable resource as bitmap, everything works well.
UPDATE:
This is the code used here;
Bitmap logo = Glide.with(context)
.load(url)
.asBitmap()
.into(80, 80)
.get();
return BlurBuilder.blur(context, logo);
And BlurBuilder is the class copied from here: Create blurry transparent background effect
Had the same problem. Solved it by setting the Glide decode format to ARGB_8888
https://github.com/bumptech/glide/wiki/Configuration#bitmap-format
I am using Fresco Image Loader in my application in which uri is loaded into SimpleDraweeView. I have a list of images, sometimes i load the same image into two different views. In this case does fresco loads the image from cache into SimpleDraweeView or does it downloads the image from the network whenever needed and also where exactly do i need to use Drawee and ImagePipeline. Please help me.
Fresco library is built specifically to address concerns like this. To answer your first question, no, the image won't be downloaded twice. It won't even be decoded twice. Fresco avoids doing any duplicate work. You should be completely fine in using the same uri in multiple views at the same time.
As for your other question, Drawee operates on an API level above ImagePipeline. Those two are not competing. ImagePipeline is to Drawee as a Wheel is to a Car. If you want to display the image you should be using Drawee and not ImagePipeline. If you need to get the actual image bytes or to do something else with the Bitmap other than displaying it, you should use the ImagePipeline.
we are using an app for setting wallpaper in android device, for that we are doing below steps
1) we have set of images and URLs
2) We are fetching the URL on an Imageview
so now we have to set the wallpaper, for that we need the image file, which is the best way to do it?
1) Download the file directly from URL and store it in a local storage and use it as wallpaper.
or
2) Create a bitmap from the Imageview and use it as wallpaper.
Doing the second option will reduce any quality of the image we using?
First option how to we can do it?
We have fetch the images successfully inside the application.
Always prefer to cache your image downloads so that you don't have to repeat the task. Using libraries like Picasso or Glide reduces a lot of effort is handling your images while at the same time optimizing your code.
Additionally it's best to use the original image as wallpaper rather than consuming the image view because if you have set any scale type's on your image view then your image will be cropped.
Picasso allows for hassle-free image loading in your application—often in one line of code!
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);