use of com.googlecode.flickrjandroid.photos.PhotosInterface in project GestureViews by alexvasilkov.
the class FlickrApi method loadImages.
@Background(singleThread = true)
@Subscribe(LOAD_IMAGES_EVENT)
private static synchronized EventResult loadImages(int count) throws Exception {
SearchParameters params = new SearchParameters();
params.setText(SEARCH_QUERY);
params.setSafeSearch(Flickr.SAFETYLEVEL_SAFE);
params.setSort(SearchParameters.INTERESTINGNESS_DESC);
params.setExtras(photoParams);
boolean hasNext = hasNext();
final PhotosInterface flickrPhotos = new Flickr(API_KEY).getPhotosInterface();
while (photos.size() < count && hasNext) {
final PhotoList loaded = flickrPhotos.search(params, PER_PAGE, pages.size() + 1);
pages.add(loaded);
photos.addAll(loaded);
hasNext = hasNext();
}
int resultSize = Math.min(photos.size(), count);
List<Photo> result = new ArrayList<>(photos.subList(0, resultSize));
if (!hasNext) {
hasNext = photos.size() > count;
}
return EventResult.create().result(result, hasNext).build();
}
Aggregations