opensource.google.com

Menu

Glide 3.0: a media management library for Android

Tuesday, September 2, 2014

Today we are happy to announce the first stable release of Glide 3.0. Glide is an 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 is specifically designed not only to be easy to use, but also to make scrolling lists of images as smooth and pleasant to use as possible. To reduce stuttery scrolling in lists caused by garbage collections due to Bitmap allocations, Glide uses reference counting behind the scenes to track and reuse Bitmap objects. To maximize the number of Bitmaps that are re-used, Glide includes a Bitmap pool capable of pooling arbitrary sizes of Bitmaps. 

The 3.0 version of Glide includes a number of improvements, including support for animated GIF and video still decoding, improved lifecycle integration to intelligently pause and restart requests, and thumbnailing support. 

Despite all of the new features, Glide’s interface is still simple and easy to use. To display an image, video still, or animated GIF in a view, you still need only one line:

Glide.with(context).load("http://goo.gl/h8qOq7").into(yourImageView);

Glide will intelligently determine the type of media you’re trying to load, decode it, and return a drawable object that can display the animation or still image in the view. If you want to load specifically a Bitmap, you can do that too:

Glide.with(context).load("http://goo.gl/h8qOq7").asBitmap().into(yourImageView);

You can also do more complex transformations. For example, to upload the bytes of a 250px by 250px profile photo for a user:

Glide.with(context)
.load("/user/profile/photo/path")
.asBitmap()
.toBytes()
.centerCrop()
.into(new SimpleTarget<byte[]>(250, 250) {
@Override
public void onResourceReady(byte[] data, GlideAnimation anim) {
// Post your bytes to a background thread and upload them here.
}
});

For a more complete list of changes, documentation, or to report issues please see the Github page. To see Glide being used in a real application, check out the recently released source of the 2014 Google I/O app and their excellent blog post on image loading. Finally, for questions, comments, or suggestions please join our discussion list.

By Sam Judd, Google Engineering

.