Loading images from a remote URL
We just learned how to extract data from an API response. That data often includes URLs to images we want to present to the user. There is quite a bit of work involved in achieving that. First, you must fetch the image as a binary stream from the URL. Then, you need to transform that binary stream into an image (it could be a GIF, JPEG, or one of a few other image formats).
Then, you need to convert it into a bitmap instance, potentially resizing it to use less memory. You may also want to apply other transformations to it at that point. Then, you need to set it to ImageView
.
Sounds like a lot of work, doesn’t it? Well, luckily for us, there are a few libraries that do all of that (and more) for us. The most commonly used libraries are Square’s Picasso (see https://square.github.io/picasso/) and Glide by Bump Technologies (see https://github.com/bumptech/glide). Facebook’s Fresco (see https://frescolib.org/) is somewhat less...