Simple use of glide library for display images on android

We know all that memory to store images on mobile is limited, if we have display images using through the bitmap images, it will take lots of memory, which is followed by ultimately memory performance and finally application will be slow.

Yes, we have new image display library call glide. Glide is the perfect and best one to use compared to Picasso and Fresco.

Reasons of using Glide:
  1. Recommended by Google and has been used in many Google open source projects.
  2. Picasso loads the full-size image (1920x1080 pixels) into the memory and let GPU does the real-time resizing when drawn. While Glide loads the exact ImageView-size (768x432 pixels) into the memory which is a best practice.
  3. Glide cache both the full-size image and the resized one. Picasso will cache only single size of image, the full-size one. Glide acts differently, caches separate file for each size of ImageView.
  4. GIF (animated image) support.
  5. In addition, it also helps preventing an app from popular OutOfMemoryError.
Fresco has huge size of library and cache also. Moreover, app freezes while loading big images from internet into ListView.
While Glide has small size of both library and cache.(Source: Quora)
Here is the pictorial difference between Glide vs Picasso vs Fresco.

Now, How to use Glide to display images on Android, Here is the simple steps,
First you have to introduces dependencies on gradle.
compile 'com.github.bumptech.glide:glide:3.5.2'
and 
On your imageview, please provide this code for display images.
image is image view , depend you requirement, 
In kotlin:
val image = currentView.findViewById(R.id.image) as ImageView

In Java

ImageView image= (ImageView) findViewById(R.id.image)

Now, render the image url on our imageview.
Glide.with(context)
.load(currentVolume.imageUrl)
.into(image)

#HappyCoding #ILoveKotlin

Circle

Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace