πŸ‘πŸ‘ Glide review πŸ‘πŸ‘

Or how to load images from the internets when you don’t know what you are doing

Costa Fotiadis
3 min readFeb 19, 2019

This is a spin-off to the β€œRetrofit review” article I wrote a while back.

You can find it here:

not this guy again

What is Glide anyway?

Glide is an image loading library developed by people smarter than me.(granted, I’m not very bright)

You can check out the official docs (https://github.com/bumptech/glide) if you are an inquisitive soul but we both know why you are here.

What you will need

Source code can be found here (although extensive code samples will be provided for easy copy pasta):

Just click File -> New project in Android Studio 3 and include Kotlin support, AndroidX artifacts and an empty activity pre-made.

Press next on everything and let Android Studio write everything for you.

Dependencies

Go to the build.gradle (Module: app) file and get it looking like this kind of:

You will also need permission to use the internet in the manifest.

When does the fun stuff start?

Who said this was going to be fun?

Get a new package created and create a Kotlin class like this:

Run the app as it is. If you don’t you will be left wondering why everything is red later.

Find a nice image or gif url you would like to load into your app.

Gonna go with this one here for the memes (https://media.giphy.com/media/cYxLgjZI5ezI2lrItX/giphy.gif).

On the plus side (or minus? i dunno), it’s quite a big file which will probably help later when we set a progress bar to show while waiting for it to load.

The layout

We need something very sophisticated to display the image.

This will do:

Still waiting for the exciting bit

Loading the url can result in an error or take a really long time cause the hamsters powering the servers are asleep.

Try to have a spinner thing when loading and an image bundled in the app that shows on error.

Wew lad

Give it a run and check what happens. Try a different url as well as an invalid one to test the error image. The Logcat will have more information too!

That’s it for now.

Later.

can we get 3 million likes guys 1 like = 1 prayer πŸ‘‰πŸ˜ŽπŸ‘‰ πŸ’―

--

--

Costa Fotiadis
Costa Fotiadis

No responses yet