1*62b6a48dSTrevor RadcliffeGlide 2*62b6a48dSTrevor Radcliffe===== 3*62b6a48dSTrevor Radcliffe 4*62b6a48dSTrevor Radcliffe[](https://travis-ci.org/bumptech/glide) 5*62b6a48dSTrevor Radcliffe 6*62b6a48dSTrevor RadcliffeGlide is a fast and efficient open source media management framework for Android that wraps media decoding, memory and 7*62b6a48dSTrevor Radcliffedisk caching, and resource pooling into a simple and easy to use interface. 8*62b6a48dSTrevor Radcliffe 9*62b6a48dSTrevor Radcliffe 10*62b6a48dSTrevor Radcliffe 11*62b6a48dSTrevor RadcliffeGlide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible api 12*62b6a48dSTrevor Radcliffethat allows developers to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based 13*62b6a48dSTrevor Radcliffestack, but also includes utility libraries plug in to Google's Volley project or Square's OkHttp library instead. 14*62b6a48dSTrevor Radcliffe 15*62b6a48dSTrevor RadcliffeGlide's primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is 16*62b6a48dSTrevor Radcliffealso effective for almost any case where you need to fetch, resize, and display a remote image. 17*62b6a48dSTrevor Radcliffe 18*62b6a48dSTrevor RadcliffeDownload 19*62b6a48dSTrevor Radcliffe-------- 20*62b6a48dSTrevor RadcliffeYou can download a jar from GitHub's [release page](https://github.com/bumptech/glide/releases). 21*62b6a48dSTrevor Radcliffe 22*62b6a48dSTrevor RadcliffeOr use Gradle: 23*62b6a48dSTrevor Radcliffe 24*62b6a48dSTrevor Radcliffe```groovy 25*62b6a48dSTrevor Radclifferepositories { 26*62b6a48dSTrevor Radcliffe mavenCentral() 27*62b6a48dSTrevor Radcliffe} 28*62b6a48dSTrevor Radcliffe 29*62b6a48dSTrevor Radcliffedependencies { 30*62b6a48dSTrevor Radcliffe compile 'com.github.bumptech.glide:glide:3.3.+' 31*62b6a48dSTrevor Radcliffe compile 'com.android.support:support-v4:19.1.0' 32*62b6a48dSTrevor Radcliffe} 33*62b6a48dSTrevor Radcliffe``` 34*62b6a48dSTrevor Radcliffe 35*62b6a48dSTrevor RadcliffeOr Maven: 36*62b6a48dSTrevor Radcliffe 37*62b6a48dSTrevor Radcliffe```xml 38*62b6a48dSTrevor Radcliffe<dependency> 39*62b6a48dSTrevor Radcliffe <groupId>com.github.bumptech.glide</groupId> 40*62b6a48dSTrevor Radcliffe <artifactId>glide</artifactId> 41*62b6a48dSTrevor Radcliffe <version>3.3.1</version> 42*62b6a48dSTrevor Radcliffe <type>aar</type> 43*62b6a48dSTrevor Radcliffe</dependency> 44*62b6a48dSTrevor Radcliffe<dependency> 45*62b6a48dSTrevor Radcliffe <groupId>com.google.android</groupId> 46*62b6a48dSTrevor Radcliffe <artifactId>support-v4</artifactId> 47*62b6a48dSTrevor Radcliffe <version>r7</version> 48*62b6a48dSTrevor Radcliffe</dependency> 49*62b6a48dSTrevor Radcliffe``` 50*62b6a48dSTrevor Radcliffe 51*62b6a48dSTrevor RadcliffeHow do I use Glide? 52*62b6a48dSTrevor Radcliffe------------------- 53*62b6a48dSTrevor RadcliffeCheckout 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*62b6a48dSTrevor Radcliffe 55*62b6a48dSTrevor RadcliffeSimple use cases will look something like this: 56*62b6a48dSTrevor Radcliffe 57*62b6a48dSTrevor Radcliffe```Java 58*62b6a48dSTrevor Radcliffe 59*62b6a48dSTrevor Radcliffe// For a simple view: 60*62b6a48dSTrevor Radcliffe@Override 61*62b6a48dSTrevor Radcliffepublic void onCreate(Bundle savedInstanceState) { 62*62b6a48dSTrevor Radcliffe ... 63*62b6a48dSTrevor Radcliffe 64*62b6a48dSTrevor Radcliffe ImageView imageView = (ImageView) findViewById(R.id.my_image_view); 65*62b6a48dSTrevor Radcliffe 66*62b6a48dSTrevor Radcliffe Glide.with(this).load("http://goo.gl/h8qOq7").into(imageView); 67*62b6a48dSTrevor Radcliffe} 68*62b6a48dSTrevor Radcliffe 69*62b6a48dSTrevor Radcliffe// For a list: 70*62b6a48dSTrevor Radcliffe@Override 71*62b6a48dSTrevor Radcliffepublic View getView(int position, View recycled, ViewGroup container) { 72*62b6a48dSTrevor Radcliffe final ImageView myImageView; 73*62b6a48dSTrevor Radcliffe if (recycled == null) { 74*62b6a48dSTrevor Radcliffe myImageView = (ImageView) inflater.inflate(R.layout.my_image_view, 75*62b6a48dSTrevor Radcliffe container, false); 76*62b6a48dSTrevor Radcliffe } else { 77*62b6a48dSTrevor Radcliffe myImageView = (ImageView) recycled; 78*62b6a48dSTrevor Radcliffe } 79*62b6a48dSTrevor Radcliffe 80*62b6a48dSTrevor Radcliffe String url = myUrls.get(position); 81*62b6a48dSTrevor Radcliffe 82*62b6a48dSTrevor Radcliffe Glide.with(myFragment) 83*62b6a48dSTrevor Radcliffe .load(url) 84*62b6a48dSTrevor Radcliffe .centerCrop() 85*62b6a48dSTrevor Radcliffe .placeholder(R.drawable.loading_spinner) 86*62b6a48dSTrevor Radcliffe .crossFade() 87*62b6a48dSTrevor Radcliffe .into(myImageView); 88*62b6a48dSTrevor Radcliffe 89*62b6a48dSTrevor Radcliffe return myImageView; 90*62b6a48dSTrevor Radcliffe} 91*62b6a48dSTrevor Radcliffe 92*62b6a48dSTrevor Radcliffe``` 93*62b6a48dSTrevor Radcliffe 94*62b6a48dSTrevor RadcliffeVolley 95*62b6a48dSTrevor Radcliffe------- 96*62b6a48dSTrevor RadcliffeVolley is now an optional dependency that can be included via a utility library. To use Volley to fetch media over http/https: 97*62b6a48dSTrevor Radcliffe 98*62b6a48dSTrevor RadcliffeWith Gradle: 99*62b6a48dSTrevor Radcliffe 100*62b6a48dSTrevor Radcliffe```groovy 101*62b6a48dSTrevor Radcliffedependencies { 102*62b6a48dSTrevor Radcliffe compile 'com.github.bumptech.glide:volley-integration:1.0.+' 103*62b6a48dSTrevor Radcliffe compile 'com.mcxiaoke.volley:library:1.0.+' 104*62b6a48dSTrevor Radcliffe} 105*62b6a48dSTrevor Radcliffe``` 106*62b6a48dSTrevor Radcliffe 107*62b6a48dSTrevor RadcliffeOr with Maven: 108*62b6a48dSTrevor Radcliffe 109*62b6a48dSTrevor Radcliffe```xml 110*62b6a48dSTrevor Radcliffe<dependency> 111*62b6a48dSTrevor Radcliffe <groupId>com.github.bumptech.glide</groupId> 112*62b6a48dSTrevor Radcliffe <artifactId>volley-integration</artifactId> 113*62b6a48dSTrevor Radcliffe <version>1.0.1</version> 114*62b6a48dSTrevor Radcliffe <type>jar</type> 115*62b6a48dSTrevor Radcliffe</dependency> 116*62b6a48dSTrevor Radcliffe<dependency> 117*62b6a48dSTrevor Radcliffe <groupId>com.mcxiaoke.volley</groupId> 118*62b6a48dSTrevor Radcliffe <artifactId>library</artifactId> 119*62b6a48dSTrevor Radcliffe <version>1.0.5</version> 120*62b6a48dSTrevor Radcliffe <type>aar</type> 121*62b6a48dSTrevor Radcliffe</dependency> 122*62b6a48dSTrevor Radcliffe``` 123*62b6a48dSTrevor Radcliffe 124*62b6a48dSTrevor RadcliffeThen in your Activity or Application, register the Volley based model loader: 125*62b6a48dSTrevor Radcliffe```java 126*62b6a48dSTrevor Radcliffepublic void onCreate() { 127*62b6a48dSTrevor Radcliffe Glide.get(this).register(GlideUrl.class, InputStream.class, 128*62b6a48dSTrevor Radcliffe new VolleyUrlLoader.Factory(yourRequestQueue)); 129*62b6a48dSTrevor Radcliffe ... 130*62b6a48dSTrevor Radcliffe} 131*62b6a48dSTrevor Radcliffe``` 132*62b6a48dSTrevor Radcliffe 133*62b6a48dSTrevor RadcliffeAfter the call to register any requests using http or https will go through Volley. 134*62b6a48dSTrevor Radcliffe 135*62b6a48dSTrevor RadcliffeOkHttp 136*62b6a48dSTrevor Radcliffe------ 137*62b6a48dSTrevor RadcliffeIn addition to Volley, Glide also includes support for fetching media using OkHttp. To use OkHttp to fetch media over http/https: 138*62b6a48dSTrevor Radcliffe 139*62b6a48dSTrevor RadcliffeWith Gradle: 140*62b6a48dSTrevor Radcliffe 141*62b6a48dSTrevor Radcliffe```groovy 142*62b6a48dSTrevor Radcliffedependencies { 143*62b6a48dSTrevor Radcliffe compile 'com.github.bumptech.glide:okhttp-integration:1.0.+' 144*62b6a48dSTrevor Radcliffe compile 'com.squareup.okhttp:okhttp:2.0.+' 145*62b6a48dSTrevor Radcliffe} 146*62b6a48dSTrevor Radcliffe``` 147*62b6a48dSTrevor Radcliffe 148*62b6a48dSTrevor RadcliffeOr with Maven: 149*62b6a48dSTrevor Radcliffe 150*62b6a48dSTrevor Radcliffe```xml 151*62b6a48dSTrevor Radcliffe<dependency> 152*62b6a48dSTrevor Radcliffe <groupId>com.github.bumptech.glide</groupId> 153*62b6a48dSTrevor Radcliffe <artifactId>okhttp-integration</artifactId> 154*62b6a48dSTrevor Radcliffe <version>1.0.1</version> 155*62b6a48dSTrevor Radcliffe <type>jar</type> 156*62b6a48dSTrevor Radcliffe</dependency> 157*62b6a48dSTrevor Radcliffe<dependency> 158*62b6a48dSTrevor Radcliffe <groupId>com.squareup.okhttp</groupId> 159*62b6a48dSTrevor Radcliffe <artifactId>okhttp</artifactId> 160*62b6a48dSTrevor Radcliffe <version>2.0.0</version> 161*62b6a48dSTrevor Radcliffe <type>jar</type> 162*62b6a48dSTrevor Radcliffe</dependency> 163*62b6a48dSTrevor Radcliffe``` 164*62b6a48dSTrevor Radcliffe 165*62b6a48dSTrevor RadcliffeThen in your Activity or Application, register the OkHttp based model loader: 166*62b6a48dSTrevor Radcliffe```java 167*62b6a48dSTrevor Radcliffepublic void onCreate() { 168*62b6a48dSTrevor Radcliffe Glide.get(this).register(GlideUrl.class, InputStream.class, 169*62b6a48dSTrevor Radcliffe new OkHttpUrlLoader.Factory(yourOkHttpClient)); 170*62b6a48dSTrevor Radcliffe ... 171*62b6a48dSTrevor Radcliffe} 172*62b6a48dSTrevor Radcliffe``` 173*62b6a48dSTrevor Radcliffe 174*62b6a48dSTrevor RadcliffeAndroid SDK Version 175*62b6a48dSTrevor Radcliffe------------------- 176*62b6a48dSTrevor RadcliffeGlide requires a minimum sdk version of 10. 177*62b6a48dSTrevor Radcliffe 178*62b6a48dSTrevor RadcliffeLicense 179*62b6a48dSTrevor Radcliffe------- 180*62b6a48dSTrevor RadcliffeBSD, part MIT and Apache 2.0. See LICENSE file for details. 181*62b6a48dSTrevor Radcliffe 182*62b6a48dSTrevor RadcliffeStatus 183*62b6a48dSTrevor Radcliffe------ 184*62b6a48dSTrevor RadcliffeVersion 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*62b6a48dSTrevor Radcliffe 186*62b6a48dSTrevor RadcliffeBuild 187*62b6a48dSTrevor Radcliffe------ 188*62b6a48dSTrevor RadcliffeBuilding Glide with gradle is fairly straight forward: 189*62b6a48dSTrevor Radcliffe 190*62b6a48dSTrevor Radcliffe``` 191*62b6a48dSTrevor Radcliffegit clone [email protected]:bumptech/glide.git 192*62b6a48dSTrevor Radcliffecd glide 193*62b6a48dSTrevor Radcliffegit submodule init && git submodule update 194*62b6a48dSTrevor Radcliffe./gradlew jar 195*62b6a48dSTrevor Radcliffe``` 196*62b6a48dSTrevor Radcliffe 197*62b6a48dSTrevor RadcliffeNote: 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*62b6a48dSTrevor Radcliffe 199*62b6a48dSTrevor RadcliffeSamples 200*62b6a48dSTrevor Radcliffe------- 201*62b6a48dSTrevor RadcliffeFollow the steps in the 'Build' section to setup the project and then: 202*62b6a48dSTrevor Radcliffe 203*62b6a48dSTrevor Radcliffe``` 204*62b6a48dSTrevor Radcliffe./gradlew :samples:flickr:run 205*62b6a48dSTrevor Radcliffe./gradlew :samples:giphy:run 206*62b6a48dSTrevor Radcliffe./gradlew :samples:svg:run 207*62b6a48dSTrevor Radcliffe``` 208*62b6a48dSTrevor Radcliffe 209*62b6a48dSTrevor RadcliffeDevelopment 210*62b6a48dSTrevor Radcliffe----------- 211*62b6a48dSTrevor RadcliffeFollow 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*62b6a48dSTrevor Radcliffe 213*62b6a48dSTrevor RadcliffeTo open the project in Intellij 14: 214*62b6a48dSTrevor Radcliffe 215*62b6a48dSTrevor Radcliffe1. Go to File. 216*62b6a48dSTrevor Radcliffe2. Click on 'Open...' 217*62b6a48dSTrevor Radcliffe3. Navigate to Glide's root directory. 218*62b6a48dSTrevor Radcliffe4. Select settings.gradle. 219*62b6a48dSTrevor Radcliffe 220*62b6a48dSTrevor RadcliffeGetting Help 221*62b6a48dSTrevor Radcliffe------------ 222*62b6a48dSTrevor RadcliffeTo 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*62b6a48dSTrevor Radcliffe 224*62b6a48dSTrevor RadcliffeContributing 225*62b6a48dSTrevor Radcliffe------------ 226*62b6a48dSTrevor RadcliffeBefore submitting pull requests, contributors must sign Google's [individual contribution license agreement](https://developers.google.com/open-source/cla/individual). 227*62b6a48dSTrevor Radcliffe 228*62b6a48dSTrevor RadcliffeThanks 229*62b6a48dSTrevor Radcliffe------ 230*62b6a48dSTrevor Radcliffe* The Android team and Jake Wharton for the [disk cache implementation](https://github.com/JakeWharton/DiskLruCache) Glide's disk cache is based on. 231*62b6a48dSTrevor Radcliffe* Dave Smith for the [gif decoder gist](https://gist.github.com/devunwired/4479231) Glide's gif decoder is based on. 232*62b6a48dSTrevor Radcliffe* Chris Banes for his [gradle-mvn-push](https://github.com/chrisbanes/gradle-mvn-push) script. 233*62b6a48dSTrevor Radcliffe* Corey Hall for Glide's [amazing logo](static/glide_logo.png). 234*62b6a48dSTrevor Radcliffe* Everyone who has contributed code and reported issues! 235*62b6a48dSTrevor Radcliffe 236*62b6a48dSTrevor RadcliffeAuthor 237*62b6a48dSTrevor Radcliffe------ 238*62b6a48dSTrevor RadcliffeSam Judd - @samajudd 239*62b6a48dSTrevor Radcliffe 240*62b6a48dSTrevor RadcliffeDisclaimer 241*62b6a48dSTrevor Radcliffe--------- 242*62b6a48dSTrevor RadcliffeThis is not an official Google product. 243