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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.