Code an Image Gallery Android App With Glide

Code an Image Gallery Android App With Glide

1. What Is Glide?

Glide is a popular open-source Android library for loading images, videos, and animated GIFs. With Glide, you can load and display media from many different sources, such as remote servers or the local file system.

By default, Glide uses a custom implementation of HttpURLConnection to load images over the internet. However, Glide also provides plugins to other popular networking libraries such as Volley or OkHttp.

2. So Why Use Glide?

Developing your own media loading and display functionality in Java can be a real pain: you have to take care of caching, decoding, managing network connections, threading, exception handling, and more. Glide is an easy to use, well planned, well documented, and thoroughly tested library that can save you a lot of precious time—and save you some headaches.

In this tutorial, we’ll learn about Glide 3 by building a simple image gallery app. It will load the images via the internet and display them as thumbnails in a RecyclerView, and when a user clicks on any image, it will open a detail activity containing the larger image.

3. Create an Android Studio Project

Fire up your Android Studio and create a new project with an empty activity called MainActivity.

4. Declare Dependencies

After creating a new project, specify the following dependencies in your build.gradle.

repositories {
  mavenCentral() // jcenter() works as well because it pulls from Maven Central
}
 
dependencies {
    // Glide
    compile 'com.github.bumptech.glide:glide:3.7.0'
     
    // Recyclerview
    compile 'com.android.support:recyclerview-v7:25.1.1'
}

Or with Maven:

<dependency>
  <groupId>com.github.bumptech.glide</groupId>
  <artifactId>glide</artifactId>
  <version>3.7.0</version>
</dependency>
<dependency>
  <groupId>com.google.android</groupId>
  <artifactId>support-v4</artifactId>
  <version>r7</version>
</dependency>

Make sure you sync your project after adding the Glide dependency.

Continue to read the full article on Tuts+.

SHARE ON