Searching Flickr
You need to update your fragment code to reflect the refactoring you just completed in FlickrFetchr.
Open PhotoGalleryFragment and update FetchItemsTask.
Listing 27.5 Hardwiring search query code (PhotoGalleryFragment.java)
public class PhotoGalleryFragment extends Fragment {
...
private class FetchItemsTask extends AsyncTask<Void,Void,List
@Override
protected List
return new FlickrFetchr().fetchItems();
String query = "robot"; // Just for testing
if (query == null) {
return new FlickrFetchr().fetchRecentPhotos();
} else {
return new FlickrFetchr().searchPhotos(query);
}
}
@Override
protected void onPostExecute(List
mItems = items;
setupAdapter();
}
}
}
If the query string is not null (which for now is always the case), then FetchItemsTask will execute a
Flickr search. Otherwise FetchItemsTask will default to fetching recent photos, just as it did before.
Hardcoding the query allows you to test out your new search code even though you have not yet
provided a way to enter a query through the UI.