commit | 15024b6111ac2bae0c55e6a07c6f0caa7abfc0cf | [log] [tgz] |
---|---|---|
author | Sam Judd <judds@google.com> | Sun Aug 17 08:46:14 2014 -0700 |
committer | Sam Judd <judds@google.com> | Sun Aug 17 12:16:53 2014 -0700 |
tree | 70f4350a48bcd6f28dab9d8e5fecb85a20bb9534 | |
parent | c17a1755acb6d4f69cab9afe09ab331832ac5095 [diff] |
Create glide subproject to generate jar
Glide is fast and efficient image loading library for Android that wraps image downloading, resizing, memory and disk caching, and bitmap recycling into one simple and easy to use interface. Glide includes a flexible api allowing it to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based stack, but also includes a utility library to plug in to Google's Volley project instead.
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.
You can download a jar from GitHub's release page or to use the 3.0 alpha branch, use Gradle:
repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { compile('com.github.bumptech.glide:library:3.3.0a-SNAPSHOT:@aar') { transitive = true changing = true } compile 'com.android.support:support-v4:19.0.0' }
Or Maven:
In your parent pom:
<parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>7</version> </parent>
In your module:
<dependency> <groupId>com.github.bumptech.glide</groupId> <artifactId>library</artifactId> <version>3.3.0-SNAPSHOT</version> <type>aar</type> </dependency> <dependency> <groupId>com.google.android</groupId> <artifactId>support-v4</artifactId> <version>r7</version> </dependency>
Volley is now an optional dependency that can be included via a utility library. More utility libraries for other projects will hopefully be coming soon. To use the utility library with Gradle, add:
dependencies { compile group: 'com.github.bumptech.glide', name:'volley', version:'3.3.0-SNAPSHOT', changing:true compile 'com.mcxiaoke.volley:library:1.0.+' }
Or with maven:
<dependency> <groupId>com.github.bumptech.glide</groupId> <artifactId>volley</artifactId> <version>3.3.0-SNAPSHOT</version> <type>aar</type> </dependency> <dependency> <groupId>com.mcxiaoke.volley</groupId> <artifactId>library</artifactId> <version>1.0.5</version> <type>aar</type> </dependency>
Then in your Activity or Application, register the Volley based model loader:
public void onCreate() { Glide.get(this).register(GlideUrl.class, InputStream.class, new VolleyUrlLoader.Factory(yourRequestQueue)); ... }
After the call to register any requests using http or https will go through Volley.
Checkout the GitHub wiki for pages on a variety of topics and links to javadocs.
Simple use cases will look something like this:
//For a simple view: @Override public void onCreate(Bundle savedInstanceState) { ... ImageView imageView = (ImageView) findViewById(R.id.my_image_view); Glide.with(this).load("http://goo.gl/h8qOq7").into(imageView); } //For a list: @Override public View getView(int position, View recycled, ViewGroup container) { final ImageView myImageView; if (recycled == null) { myImageView = (ImageView) inflater.inflate(R.layout.my_image_view, container, false); } else { myImageView = (ImageView) recycled; } String url = myUrls.get(position); Glide.with(myFragment) .load(url) .centerCrop() .placeholder(R.drawable.loading_spinner) .animate(R.anim.fade_in) .into(myImageView); return myImageView; }
Glide was used at Bump for around a year in two of our Android apps at version 1.0. Version 2.0 was the first public release with a stable api. Version 3.0 is a work in progress and is in use in open source projects at Google including in the Android Camera app and in the 2014 Google IO app. Comments/bugs/questions/pull requests welcome!
Building Glide with gradle is fairly straight forward:
git clone git@github.com:bumptech/glide.git cd glide git checkout origin/3.0a git submodule init && git submodule update ./gradlew build releaseJar
Note: Make sure your Android SDK has the Android Support Repository installed, and that your $ANDROID_HOME
environment variable is pointing at the SDK.
Thanks to the Android project and Jake Wharton for the disk cache implementation included with Glide. Thanks also to the Android team for Volley. Thanks to Dave Smith for his GifDecoder gist on which Glide's is based. Thanks also to everyone who has contributed code and reported issues!
Sam Judd - @samajudd