Hi all,
also today I went to one of the wonderful meetups of SkillsMatter. This time I attended the talk of the meetup droidcon Bytes whose topic was “Advanced Image Handling Techniques with Michael Tweed“. I should have checked the topic of the meetup, I thought it was something more generic, not only related to Android, but anyway it was nice.
Michael Tweed (LinkedIN) is a developer in Sky. He worked there for the last 5 years as Android developer. He started his talk with an ancient question that every Android developer asked in their life: “how to load an image from an URL into an ImageViewer” or “how to lazily load images in a ListView“. Those two questions have more than 500.000 views on Stack Overflow. At the very beginning the problem was also to do that taking care of memory problems.
He then introduced three tools for addressing in a very easy and powerful way this problems: Glide, fresco and the one adopted by Sky, Picasso. The three libraries are opensource, and Glide and Picasso especially are so similar that you can find long and interesting blog posts on their comparisons.
After this introduction to the library, he explained how it was important to minimise the work on the android device, and for doing that in Sky they set up a server for images from which you can request size and quality of the image, instead of scaling or computing dimensions on the device. Having a small amount of choices for the quality (like low, medium and high) helped to cache the different images. Determining which quality to retrieve “is not an exact science” (as he said): key factors are wifi or mobile data, available memory or “type of image” (meaning that new features, or big events, need a better quality to be more attractive).
Picasso can be used with other libraries, like OkHttp (OkHttpDownloader) that is useful for caching similar requests, and you can easily extend it to add your logic to any RequestHandler (they added another custom level of caching, for example), or you can add priorities to image downloads, to specify which image has the highest priority (for example, big central images may be needed before than small Sky’s logos), or add tags, like groups, that let you stop or resume the downloading of some images (this becomes really useful for scrolling, because you don’t want to download something you won’t see).
Last part of the talk was related to a new feature of the box Sky gives you with the broadband: you can basically send pictures or slideshows of pictures directly to your tv. For this specific app there were some challenges: display grid of images on the device, images had to be fixed dimensions and below a certain size and the sending of the single image should be performed within a certain time frame.
This ended the talk.
Stay tuned!
Leave a Reply