Glide
Glide
is a fast and efficient open source media management framework for
Android that wraps media decoding, memory and disk caching, and
resource pooling into a simple and easy to use interface.
Glide's
primary focus is on making scrolling any kind of a list of images as
smooth and fast as possible, but Glide is also effective for almost
any case where you need to fetch, resize, and display a remote image.
Implementation / Usage
Let
Looks the implementation of Picasso and Glide.
Using
the Picasso or Glide are easy and straight forward.
Advantage
of Glide here is... Inbuilt it supports caching...
Let
us assume, I am having two ImageView where one is loaded with Picasso
and othere with Glide as shown below.
// Picasso
ImageView imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "Image 1");
}
});
Picasso.with(this).load("http://i.imgur.com/DvpvklR.png").into(imageView);
// Glide
ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
imageView2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "Image 2");
}
});
Glide.with(this).load("http://i.imgur.com/DvpvklR.png").into(imageView2);
Run
the application by connecting to the internet, We can see downloading
the images repsectively.
Know
turn off internet connection and kill the application from recent
apps and now launch application we can see the imageview2(Glide) is
loaded but not imageview1 (Picasso).
New Features
Glide
version 3.x supports large number of features...
- Animated GIF decoding
- Local video stills
- Thumbnail support
- Lifecycle integration
- Transcoding
- Animations
- OkHttp and Volley Support
Including
the ability to use Drawables objects as placeholders during loads,
request prioritization, width and height overrides and the ability to
cache transformed thumbnails and/or the original source.
By
default Glide uses a custom HttpUrlConnection based stack, but also
includes utility libraries plug in to Google's Volley project or
Square's OkHttp library instead.
In
addition to the new features introduced in the the 3.x version, Glide
carries over all of the originals from the 2.x version:
- Background image loading.
- Automatic job cancellation in lists where views are re-used.
- Memory and disk caching
- Bitmap and resource pooling to minimize jank.
- Arbitrary transformations.
There
are pros and cons in any library and I am not supporting any of the
tool/library here.
Thanks for reading :)
Whether this post is helpful?
Have something to add to this post? If you have any other quick thoughts/hints that you think people will find useful? Share it in the comments, feedback are welcome...
Hi Harsha ,
ReplyDeleteNice Post , I have to decide on which library to use for my app which revolves around getting images from internet,displaying it with least amount of ghosting and caching the images (the library should provide good control over caching) ,which one would you suggest ? Glide or Picasso .There are also Universal Image loader and Ion.
Glide & Picasso both are better than Universal Image loader but If you want to decide between Glide and Picasso then it is depend upon the project needs. assume if you're not having fallback urls then go with Glide otherwise I prefer Picasso. Glide is a single jar file, which handles everything but picasso for caching you should use okhttp.
DeleteHi Vardhan
ReplyDeleteI have a doubt. my requirement is once i downloaded image from server i have to store those images in directory as a cache, how to do this using glide ?? how to store and retrieve in directory using glide
Thanks
How to use Glide in Fragment? Will you please give me Source code for it
ReplyDelete