I am trying to load a lot of images from server using Android Volley library.
I am curious to, is there any way i can find out the % progress of the image being downloaded.
ImageLoader contains onError and onSuccess only. If not, is there any better library to provide this functionality?
In your situation, you made loading an image as download a file, ImageLoader basically perform a single-session request, does not fulfill your purpose. if you still looking for a library that advantage by Volley but offered a file downloader implementation, then you have Netroid.
you can perform a download request for your image, that make you be capable of showing the progress, once download successfully, you perform loading the local file as a Bitmap to display into ImageView. this approach was indirectly but i think it work for you.
Related
I have the opentok-archiving sample application set up. While playing the archives, I need thumbnails for the archive. Does OpenTok provide thumbnails?
Currently, I think the only way is to setup Archiving URL callback, and once the archive status is changed to uploaded, I need to get a thumbnail out of the video on my backend.
Are there any other better ways to go about this?
(Myself: tokbox developer)
No, OpenTok does not provide a thumbnail of the archives. However, you can create the thumbnails yourself very easily with ffmpeg.
I am using the AppIntro library for an app in Android and I want to download the images from my Firebase Storage, I am familiar with Glide and I have actually used it. The problem is that I haven't found any solution on how to access the ImageView so that I can use the into() function from Glide, and I haven't found a way to get the picture as a Drawable resource.
Yes it is possible .... But you will need to implement your firebase functionality within Fragments.
You can set your own fragments in APP INTRO LIBRARY with your own
views and functionalities.
My app loads and display thumbnails of top movies from a server via API. I don't want to query server and reload it every-time, I use glide to display images from server url.
How do i implement this image caching so that app uses previously loaded data, even if its offline.
Is there any library or do i have to store the images using sqlite and retrieve it ?
Thank you
If you use Glide to load the images, there is an extremely simple one-liner to cache all images.
Simple add '.diskCacheStrategy(DiskCacheStrategy.SOURCE)' to your Glide loading, and it'll cache the image, and use it even if you're offline.
So it could look like this:
Glide.with(context)
.load(imageUrl)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(target);
You should take a look at the introduction to Glide, on their official github repo. It mentions a lot of details about how it works.
If not what is a good way to cache images locally?
-- Note: I am coding for Android.
Picasso.
Many common pitfalls of image loading on Android are handled
automatically by Picasso:
Handling ImageView recycling and download cancelation in an adapter.
Complex image transformations with minimal memory use.
Automatic memory and disk caching.
When you want to send the image to your cloud, you could use ParseFile in conjunction with Picasso, get the bytes from the image and save() or saveInBackground().
My app shows images to user one after one. The images are downloaded from server. As I do not want the user to wait for the images to be downloaded I cached those in a local file system (say new 50 images) .
Implementation:
from onCreate method start a AsyncTask that will keep in downloading images in background.
Is AsyncTask best for this use case?I do not want to use a Service as I do not want the download to happen continuously
Is AsyncTask best for this purpose?
I would suggest using an existing library, such as Picasso (by Square) or Volley (by Google).
Picasso is especially easy to implement and will work excellently for your purpose, and is as easy as:
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
You won't have to concern yourself with AsyncTasks or AsyncTaskLoaders as the library takes all of this out of your hands, caching both images in memory and on the disk.
If you insist on building your own solution, I suggest looking around for related questions as there are many things to bear in mind:
AsyncTasks may be ill fitted as they are directly coupled with a single activity; you'll need a Loader or a mechanism similar to Loaders to deliver results to whichever activity wants an image.
On older devices, bitmaps reside in a special region of memory that isn't managed by the GC; you'll have to dispose of bitmaps manually when you're done with them.
Bitmaps use a significant amount of memory and need to be carefully managed to avoid OOMEs, such as downsampling them when loading and storing in memory inside an LruCache.
Beware of managing the size of the image cache directory when writing images to disk.
Yes, you can use Asynctask for this purpose. And using one of the apis of Asynctask "onProgressUpdate(), you can in parallel update the UI as your images are getting downloaded.
you can use universalImageLoader library for downloading images in an efficient way.
see this how to use universal Image loader for downloading images
One more solution for your requirement is Volley Library