use of com.flickr4java.flickr.FlickrException in project data-transfer-project by google.
the class FlickrPhotoService method getPhotos.
private PhotosModelWrapper getPhotos(String photosetId, Optional<PaginationInformation> paginationInformation) throws IOException {
try {
int page = getPage(paginationInformation);
PhotoList<Photo> photoSetList;
if (null == photosetId) {
RequestContext.getRequestContext().setExtras(EXTRAS);
photoSetList = photosInterface.getNotInSet(PHOTO_PER_PAGE, page);
RequestContext.getRequestContext().setExtras(ImmutableList.of());
} else {
photoSetList = photosetsInterface.getPhotos(photosetId, ImmutableSet.copyOf(EXTRAS), 0, PHOTO_PER_PAGE, page);
}
boolean hasMore = photoSetList.getPage() != photoSetList.getPages() && !photoSetList.isEmpty();
Collection<PhotoModel> photos = photoSetList.stream().map(p -> toCommonPhoto(p, photosetId)).collect(Collectors.toList());
FlickrPaginationInformation newPage = null;
if (hasMore) {
newPage = new FlickrPaginationInformation(page + 1);
}
return new PhotosModelWrapper(null, photos, new ContinuationInformation(null, newPage));
} catch (FlickrException e) {
throw new IOException("Couldn't fetch photos in album: " + photosetId, e);
}
}
use of com.flickr4java.flickr.FlickrException in project osm-contributor by jawg.
the class GetFlickrPhotos method doInBackground.
@Override
protected List<List<Size>> doInBackground(Void... params) {
// Create search tags list
ArrayList<String> searchTags = new ArrayList<String>(TAGS);
searchTags.add(new StringBuilder("osm:").append((featurePoi.getWay()) ? "way" : "node").append("=").append(featurePoi.getBackendId()).toString());
SearchParameters parameters = new SearchParameters();
parameters.setLatitude(String.valueOf(latitude));
parameters.setLongitude(String.valueOf(longitude));
parameters.setRadius(RADIUS);
parameters.setTags(searchTags.toArray(new String[searchTags.size()]));
parameters.setSort(SearchParameters.INTERESTINGNESS_DESC);
if (!isCancelled()) {
try {
PhotoList<Photo> photos = flickr.getPhotosInterface().search(parameters, limitPerPage, nbPage);
List<List<Size>> photosList = new ArrayList<>();
for (Photo photo : photos) {
photosList.add((List<Size>) flickr.getPhotosInterface().getSizes(photo.getId()));
}
return photosList;
} catch (FlickrException e) {
e.printStackTrace();
}
}
return null;
}
Aggregations