For the More Curious: Managing Dependencies

FlickrFetchr provides a layer of abstraction over the source of Flickr photo metadata. Other components (such as PhotoGalleryFragment) use this abstraction to fetch Flickr data without worrying about where the data is coming from.

FlickrFetchr itself does not know how to download JSON data from Flickr. Instead, FlickrFetchr relies on FlickrApi to know the endpoint URL, to connect to that endpoint, and to perform the actual work of downloading the JSON data. FlickrFetchr is said to have a dependency on FlickrApi.

You are initializing FlickrApi inside the FlickrFetchr init block:

 class FlickrFetchr { ... private val flickrApi: FlickrApi init { val retrofit: Retrofit = Retrofit.Builder() ...

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.