Challenge: Improving ThumbnailDownloader’s Lifecycle Awareness

LiveData is a lifecycle-aware component that removes itself as an observer automatically based on events from its lifecycle owner. Update ThumbnailDownloader so that it will remove itself as an observer automatically when the lifecycle it observes emits an ON_DESTROY event. To do this, ThumbnailDownloader will need a reference to each of the lifecycles it observes.

The fact that ThumbnailDownloader observes both the fragment lifecycle and the fragment view lifecycle tightly couples ThumbnailDownloader to Fragment. There are many different ways to clean this up, but here we ask you to take one small step: Refactor ThumbnailDownloader so that it only observes the fragment ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.