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

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