Loading images and caching them with Fresco in Android
I am working for a Start Up project – DiagramArt, where we needed to create Android application which : load list of diagrams from API, show these diagrams to the user and some other stuff of course. The list consists from a preview picture, diagram’s title and its description. There is no problem to load and show these data, the problem was in the preview picture.
When you want to show these information in some list, you have to create your own Adapter
and override getView
method. Then a strange bug occured : the preview pictures were changing “randomly”. Why? Because of memory saving, the system creates only a few rows and when you scroll, the list calls getView
on the visible rows. That means, the rows are always the same, only the content are changing. So whenever you scroll down and up, it was loading the pictures again and again.
Fresco
I wrote about my problem to my friends on skype and they recommended me Fresco library from Facebook. It solves these problems for you. Loads the image from the internet and cache it.