Glide is one of most used image loading library in the world for the android applications. This library provides the number of features. It’s syntax and mechanism looks like Picasso image loading library. But this is the difference from the Picasso on basis of the way how it downloads images, caches images and loads them into memory.
So in this blog, we will see some basic introduction and use of this library in our android application for loading images.
Introduction
Glide is the image library which is used for the loading the image in android app. The size of Glide image library is around 476KB and there is 2879 method count. Glide is on
Glide is on jcenter. And we can simply import this library in our android project.
123 dependencies {compile 'com.github.bumptech.glide:glide:3.7.0'}
How to use
This library’s syntax is all most same with the Picasso library for the load the image in the Imageview.
Picasso:
1234 Picasso.with(view.getContext()).load(imageUrl).placeholder(R.drawable.placeholder).into(view, utils.getCallBack(view));
Glide:
123456 Glide.with(view.getContext()).load(imageUrl).placeholder(R.drawable.placeholder).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).dontAnimate().into(view);
.skipMemoryCache(true) : we called this method for skip the memory cache. This means that Glide will not put the image in the memory cache. It’s important to understand, that this only affects the memory cache! Glide will still utilize the disk cache to avoid another network request.
.diskCacheStrategy(DiskCacheStrategy.NONE)) : There are four types of the DiskCacheStrategy which can be used,
ALL: with both {@link #SOURCE} and {@link #RESULT}. */
NONE: /** Saves no data to cache. */
SOURCE: /** Saves just the original data to cache. */
RESULT: /** Saves the media item after all transformations to cache. */
Thanks for reading this blog, if you have any questions or problems ask in the comment section.
Happy Coding. Stay Super.