Glide-Generate Thumbnail from PDF File Using Custom Loader

Rufan Khokhar
1 min readNov 29, 2020

Photo by Ilya Pavlov on Unsplash

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.

Implementation Step:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Rufan Khokhar
Rufan Khokhar

Written by Rufan Khokhar

Experienced Android Developer with a demonstrated history of working in the information technology and services industry.

No responses yet

Write a response