Chapter 27 Search
Now add methods to kick off the download by building a URL and calling
downloadGalleryItems(String).
Listing 27.4 Adding methods to get recents and search (FlickrFetchr.java)
public class FlickrFetchr {
...
public String getUrlString(String urlSpec) throws IOException {
return new String(getUrlBytes(urlSpec));
}
public List
String url = buildUrl(FETCH_RECENTS_METHOD, null);
return downloadGalleryItems(url);
}
public List
String url = buildUrl(SEARCH_METHOD, query);
return downloadGalleryItems(url);
}
private List
List
...
return items;
}
...
}
FlickrFetchr is now equipped to handle both searching and getting recent photos. The
fetchRecentPhotos() and searchPhotos(String) methods serve as the public interface for getting a
list of GalleryItems from the Flickr web service.