README.md
1 Glide
2 =====
3
4 [![Build Status](https://travis-ci.org/bumptech/glide.svg?branch=master)](https://travis-ci.org/bumptech/glide)
5
6 Glide is a fast and efficient open source media management framework for Android that wraps media decoding, memory and
7 disk caching, and resource pooling into a simple and easy to use interface.
8
9 ![](static/glide_logo.png)
10
11 Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible api
12 that allows developers to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based
13 stack, but also includes utility libraries plug in to Google's Volley project or Square's OkHttp library instead.
14
15 Glide's primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is
16 also effective for almost any case where you need to fetch, resize, and display a remote image.
17
18 Download
19 --------
20 You can download a jar from GitHub's [release page](https://github.com/bumptech/glide/releases).
21
22 Or use Gradle:
23
24 ```groovy
25 repositories {
26 mavenCentral()
27 }
28
29 dependencies {
30 compile 'com.github.bumptech.glide:glide:3.3.+'
31 compile 'com.android.support:support-v4:19.1.0'
32 }
33 ```
34
35 Or Maven:
36
37 ```xml
38 <dependency>
39 <groupId>com.github.bumptech.glide</groupId>
40 <artifactId>glide</artifactId>
41 <version>3.3.1</version>
42 <type>aar</type>
43 </dependency>
44 <dependency>
45 <groupId>com.google.android</groupId>
46 <artifactId>support-v4</artifactId>
47 <version>r7</version>
48 </dependency>
49 ```
50
51 How do I use Glide?
52 -------------------
53 Checkout the [GitHub wiki](https://github.com/bumptech/glide/wiki) for pages on a variety of topics, and see the [javadocs](http://bumptech.github.io/glide/javadocs/latest/index.html).
54
55 Simple use cases will look something like this:
56
57 ```Java
58
59 // For a simple view:
60 @Override
61 public void onCreate(Bundle savedInstanceState) {
62 ...
63
64 ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
65
66 Glide.with(this).load("http://goo.gl/h8qOq7").into(imageView);
67 }
68
69 // For a list:
70 @Override
71 public View getView(int position, View recycled, ViewGroup container) {
72 final ImageView myImageView;
73 if (recycled == null) {
74 myImageView = (ImageView) inflater.inflate(R.layout.my_image_view,
75 container, false);
76 } else {
77 myImageView = (ImageView) recycled;
78 }
79
80 String url = myUrls.get(position);
81
82 Glide.with(myFragment)
83 .load(url)
84 .centerCrop()
85 .placeholder(R.drawable.loading_spinner)
86 .crossFade()
87 .into(myImageView);
88
89 return myImageView;
90 }
91
92 ```
93
94 Volley
95 -------
96 Volley is now an optional dependency that can be included via a utility library. To use Volley to fetch media over http/https:
97
98 With Gradle:
99
100 ```groovy
101 dependencies {
102 compile 'com.github.bumptech.glide:volley-integration:1.0.+'
103 compile 'com.mcxiaoke.volley:library:1.0.+'
104 }
105 ```
106
107 Or with Maven:
108
109 ```xml
110 <dependency>
111 <groupId>com.github.bumptech.glide</groupId>
112 <artifactId>volley-integration</artifactId>
113 <version>1.0.1</version>
114 <type>jar</type>
115 </dependency>
116 <dependency>
117 <groupId>com.mcxiaoke.volley</groupId>
118 <artifactId>library</artifactId>
119 <version>1.0.5</version>
120 <type>aar</type>
121 </dependency>
122 ```
123
124 Then in your Activity or Application, register the Volley based model loader:
125 ```java
126 public void onCreate() {
127 Glide.get(this).register(GlideUrl.class, InputStream.class,
128 new VolleyUrlLoader.Factory(yourRequestQueue));
129 ...
130 }
131 ```
132
133 After the call to register any requests using http or https will go through Volley.
134
135 OkHttp
136 ------
137 In addition to Volley, Glide also includes support for fetching media using OkHttp. To use OkHttp to fetch media over http/https:
138
139 With Gradle:
140
141 ```groovy
142 dependencies {
143 compile 'com.github.bumptech.glide:okhttp-integration:1.0.+'
144 compile 'com.squareup.okhttp:okhttp:2.0.+'
145 }
146 ```
147
148 Or with Maven:
149
150 ```xml
151 <dependency>
152 <groupId>com.github.bumptech.glide</groupId>
153 <artifactId>okhttp-integration</artifactId>
154 <version>1.0.1</version>
155 <type>jar</type>
156 </dependency>
157 <dependency>
158 <groupId>com.squareup.okhttp</groupId>
159 <artifactId>okhttp</artifactId>
160 <version>2.0.0</version>
161 <type>jar</type>
162 </dependency>
163 ```
164
165 Then in your Activity or Application, register the OkHttp based model loader:
166 ```java
167 public void onCreate() {
168 Glide.get(this).register(GlideUrl.class, InputStream.class,
169 new OkHttpUrlLoader.Factory(yourOkHttpClient));
170 ...
171 }
172 ```
173
174 Android SDK Version
175 -------------------
176 Glide requires a minimum sdk version of 10.
177
178 License
179 -------
180 BSD, part MIT and Apache 2.0. See LICENSE file for details.
181
182 Status
183 ------
184 Version 3.x is a stable public release used in multiple open source projects at Google including in the Android Camera app and in the 2014 Google IO app. Comments/bugs/questions/pull requests welcome!
185
186 Build
187 ------
188 Building Glide with gradle is fairly straight forward:
189
190 ```
191 git clone git (a] github.com:bumptech/glide.git
192 cd glide
193 git submodule init && git submodule update
194 ./gradlew jar
195 ```
196
197 Note: Make sure your Android SDK has the Android Support Repository installed, and that your `$ANDROID_HOME` environment variable is pointing at the SDK or add a `local.properties` file in the root project with a `sdk.dir=...` line.
198
199 Samples
200 -------
201 Follow the steps in the 'Build' section to setup the project and then:
202
203 ```
204 ./gradlew :samples:flickr:run
205 ./gradlew :samples:giphy:run
206 ./gradlew :samples:svg:run
207 ```
208
209 Development
210 -----------
211 Follow the steps in the 'Build' section to setup the project and then edit the files however you wish. Intellij's [IDEA 14 early access build](http://confluence.jetbrains.com/display/IDEADEV/IDEA+14+EAP) cleanly imports both Glide's source and tests and is the recommended way to work with Glide. Earlier versions of intellij do not import the gradle project cleanly. Although Android Studio imports the source cleanly, it is not possible to run or debug the tests without manually modifying the tests' classpath.
212
213 To open the project in Intellij 14:
214
215 1. Go to File.
216 2. Click on 'Open...'
217 3. Navigate to Glide's root directory.
218 4. Select settings.gradle.
219
220 Getting Help
221 ------------
222 To report a specific problem or feature request, [open a new issue on Github](https://github.com/bumptech/glide/issues/new). For questions, suggestions, or anything else, join or email [Glide's discussion group](https://groups.google.com/forum/#!forum/glidelibrary)
223
224 Contributing
225 ------------
226 Before submitting pull requests, contributors must sign Google's [individual contribution license agreement](https://developers.google.com/open-source/cla/individual).
227
228 Thanks
229 ------
230 * The Android team and Jake Wharton for the [disk cache implementation](https://github.com/JakeWharton/DiskLruCache) Glide's disk cache is based on.
231 * Dave Smith for the [gif decoder gist](https://gist.github.com/devunwired/4479231) Glide's gif decoder is based on.
232 * Chris Banes for his [gradle-mvn-push](https://github.com/chrisbanes/gradle-mvn-push) script.
233 * Corey Hall for Glide's [amazing logo](static/glide_logo.png).
234 * Everyone who has contributed code and reported issues!
235
236 Author
237 ------
238 Sam Judd - @samajudd
239
240 Disclaimer
241 ---------
242 This is not an official Google product.
243