/** * Parse a list of Photos from given Element. * * @param photosElement * @return PhotoList */ public static final PhotoList<Photo> createPhotoList(Element photosElement) { PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage(photosElement.getAttribute("page")); photos.setPages(photosElement.getAttribute("pages")); photos.setPerPage(photosElement.getAttribute("perpage")); photos.setTotal(photosElement.getAttribute("total")); NodeList photoNodes = photosElement.getElementsByTagName("photo"); for (int i = 0; i < photoNodes.getLength(); i++) { Element photoElement = (Element) photoNodes.item(i); photos.add(PhotoUtils.createPhoto(photoElement)); } return photos; }
PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage(photosElement.getAttribute("page")); photos.setPerPage(photosElement.getAttribute("perpage")); photo.setFriendFlag("1".equals(photoElement.getAttribute("isfriend"))); photo.setFamilyFlag("1".equals(photoElement.getAttribute("isfamily"))); photos.add(photo);
/** * * @param response */ private PhotoList<Photo> parsePopularPhotos(Response response) { Element payload = response.getPayload(); PhotoList<Photo> photos = new PhotoList<Photo>(); NodeList photoElements = payload.getElementsByTagName("photo"); for (int i = 0; i < photoElements.getLength(); i++) { Element photoElement = (Element) photoElements.item(i); Photo photo = PhotoUtils.createPhoto(photoElement); Element statsElement = XMLUtilities.getChild(photoElement, "stats"); Stats stats = parseStats(statsElement); photo.setStats(stats); photos.add(photo); } return photos; }
@Override protected PhotoList<Photo> flickrProcess(String path) { try { final CollectionsInterface collectionsInterface = flickr.getCollectionsInterface(); final Matcher matcher = r.matcher(path); matcher.find(); final String userName = matcher.group(1); final String collectionsId = matcher.group(2); final List<Collection> collections = collectionsInterface.getTree(collectionsId, userName); final PhotoList<Photo> pl = new PhotoList<Photo>(); for (final Collection c : collections) pl.addAll(c.getPhotos()); return pl; } catch (final Exception e) { e.printStackTrace(); } return null; }
@Override public Set<IndependentPair<URL, Map<String, String>>> prepareURLs(URL url) throws ImageCollectionSetupException { System.out.println("Flickr query was: " + url.getFile()); PhotoList<Photo> results = null; try { results = flickrProcess(url.getPath()); } catch (final Exception e) { e.printStackTrace(); System.err.println("Failed performing flickr query"); return null; } final Set<IndependentPair<URL, Map<String, String>>> urls = new HashSet<IndependentPair<URL, Map<String, String>>>(); for (int i = 0; i < results.size(); i++) { final Map<String, String> meta = new HashMap<String, String>(); final Photo photo = results.get(i); meta.put("flickr_photo_id", photo.getId()); try { urls.add(IndependentPair.pair(new URL(photo.getMediumUrl()), meta)); } catch (final MalformedURLException e) { } } return urls; }
/** * Parse a list of Photos from given Element. * * @param photosElement * @return PhotoList */ public static final PhotoList<Photo> createPhotoList(Element photosElement) { PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage(photosElement.getAttribute("page")); photos.setPages(photosElement.getAttribute("pages")); photos.setPerPage(photosElement.getAttribute("perpage")); photos.setTotal(photosElement.getAttribute("total")); NodeList photoNodes = photosElement.getElementsByTagName("photo"); for (int i = 0; i < photoNodes.getLength(); i++) { Element photoElement = (Element) photoNodes.item(i); photos.add(PhotoUtils.createPhoto(photoElement)); } return photos; }
PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage(photosElement.getAttribute("page")); photos.setPerPage(photosElement.getAttribute("perpage")); photo.setFriendFlag("1".equals(photoElement.getAttribute("isfriend"))); photo.setFamilyFlag("1".equals(photoElement.getAttribute("isfamily"))); photos.add(photo);
/** * * @param response */ private PhotoList<Photo> parsePopularPhotos(Response response) { Element payload = response.getPayload(); PhotoList<Photo> photos = new PhotoList<Photo>(); NodeList photoElements = payload.getElementsByTagName("photo"); for (int i = 0; i < photoElements.getLength(); i++) { Element photoElement = (Element) photoElements.item(i); Photo photo = PhotoUtils.createPhoto(photoElement); Element statsElement = XMLUtilities.getChild(photoElement, "stats"); Stats stats = parseStats(statsElement); photo.setStats(stats); photos.add(photo); } return photos; }
PhotoList<Photo> photos = new PhotoList<Photo>(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_GET_CLUSTER_PHOTOS); photos.setPage("1"); photos.setPages("1"); photos.setPerPage("" + photoNodes.getLength()); photos.setTotal("" + photoNodes.getLength()); for (int i = 0; i < photoNodes.getLength(); i++) { Element photoElement = (Element) photoNodes.item(i); photos.add(PhotoUtils.createPhoto(photoElement));
PhotoList<Photo> photos = new PhotoList<Photo>(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_GET_CLUSTER_PHOTOS); photos.setPage("1"); photos.setPages("1"); photos.setPerPage("" + photoNodes.getLength()); photos.setTotal("" + photoNodes.getLength()); for (int i = 0; i < photoNodes.getLength(); i++) { Element photoElement = (Element) photoNodes.item(i); photos.add(PhotoUtils.createPhoto(photoElement));
public PhotoList<Photo> getContactsPublicPhotos(String userId, Set<String> extras, int count, boolean justFriends, boolean singlePhoto, boolean includeSelf) throws FlickrException { PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage("1"); photos.setPages("1"); photos.setPerPage("" + photoNodes.getLength()); photos.setTotal("" + photoNodes.getLength()); for (int i = 0; i < photoNodes.getLength(); i++) { Element photoElement = (Element) photoNodes.item(i); photos.add(PhotoUtils.createPhoto(photoElement));
PhotoList<Photo> photos = new PhotoList<Photo>(); photos.setPage(photosElement.getAttribute("page")); photos.setPages(photosElement.getAttribute("pages")); photos.setPerPage(photosElement.getAttribute("perpage")); photos.setTotal(photosElement.getAttribute("total")); photos.add(PhotoUtils.createPhoto(photoElement));