Skip to content

Commit f573cb9

Browse files
authored
Merge pull request boncey#355 from rsadasiv/master
set stats on Photo objects if requested via extras in SearchParameters
2 parents daa4a90 + c1fc29e commit f573cb9

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.flickr4java</groupId>
66
<artifactId>flickr4java</artifactId>
7-
<version>3.0.3-SNAPSHOT</version>
7+
<version>3.0.4-SNAPSHOT</version>
88
<packaging>jar</packaging>
99
<name>flickr4java</name>
1010
<description>Java API For Flickr. Fork of FlickrJ.</description>

src/main/java/com/flickr4java/flickr/photos/PhotoUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.flickr4java.flickr.people.User;
44
import com.flickr4java.flickr.places.Place;
5+
import com.flickr4java.flickr.stats.Stats;
56
import com.flickr4java.flickr.tags.Tag;
67
import com.flickr4java.flickr.util.XMLUtilities;
78

@@ -489,6 +490,17 @@ public static final Photo createPhoto(Element photoElement, Element defaultEleme
489490
} catch (IndexOutOfBoundsException e) {
490491
} catch (NullPointerException e) {
491492
}
493+
494+
//set stats from extras (count_faves,count_comments,count_views)
495+
try {
496+
Stats stats = new Stats();;
497+
stats.setFavorites(photoElement.getAttribute("count_faves"));
498+
stats.setComments(photoElement.getAttribute("count_comments"));
499+
stats.setViews(photoElement.getAttribute("count_views"));
500+
photo.setStats(stats);
501+
} catch (IndexOutOfBoundsException e) {
502+
} catch (NullPointerException e) {
503+
}
492504

493505
return photo;
494506
}

src/main/java/com/flickr4java/flickr/photos/SearchParameters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public String getMachineTagMode() {
302302

303303
/**
304304
* List of extra information to fetch for each returned record. Currently supported fields are: license, date_upload, date_taken, owner_name, icon_server,
305-
* original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_m, url_l, url_o
305+
* original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_m, url_l, url_o,count_faves,count_comments,count_views
306306
*
307307
* @param extras
308308
* A set of extra-attributes

0 commit comments

Comments
 (0)