Glide-Generate Thumbnail from PDF File Using Custom Loader
In this post, you will learn, how to create Custom Loader using Glide in 4 simple steps.
Step-1
add the following Dependencies in your app-level build.gradle file
Step-2
Now create Your Custom loader class, called ‘ThumbnailBuilder.java’, and implements the interface ModelLoader<String,Bitmap>.
ModelLoader takes two generics values First is the input and the Second is output.
In my case, I’m giving String File address as input and Thumbnail Image as Bitmap, as an output.
Example code:
Step-3
now create ‘ThumbnailBuilderFactory.java’ class and implements ‘ModelLoaderFactory<String,Bitmap> interface.
This class is the helper class for creating the ‘ThumbnailBuiler’ class Object.
Step-4
Now create a Glide App module for creating OR compiling the ThumnailBuilder class using ThumbnailBuilderFactory.
GlideAppModule converts ThumbnailBuilder class as Default OR Build in loader.