Skip to content

Commit

Permalink
Accommodate new Flickr picture sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbriccetti committed Aug 21, 2010
1 parent a6d0aed commit ac43f1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.davebsoft</groupId>
<artifactId>birdshow</artifactId>
<version>1.1</version>
<version>1.2</version>
<packaging>war</packaging>
<name>birdshow</name>
<inceptionYear>2009</inceptionYear>
Expand Down
17 changes: 10 additions & 7 deletions src/main/scala/birdshow/model/flickr/PictureIdAndSizes.scala
Expand Up @@ -6,18 +6,21 @@ case class PictureSize(val sizeName: String, val url: String)

case class PictureIdAndSizes(val id: String, val sizes: Seq[PictureSize]) {
private val SmallSizeName = "Small" // Avoid duplicating literal

private val sizeSelectionOrder = Map(
"Large" -> 1,
"Medium" -> 2,
SmallSizeName -> 3,
"Original" -> 4,
"Thumbnail" -> 5,
"Square" -> 6
"Medium 640" -> 2,
"Medium 500" -> 3,
"Medium" -> 4, // Still exists?
SmallSizeName -> 5,
"Original" -> 6,
"Thumbnail" -> 7,
"Square" -> 8
)

def getPreferredSizeUrl: String = {
sizes.toList.sort((a,b) => sizeSelectionOrder(a.sizeName) < sizeSelectionOrder(b.sizeName))(0).url
def getOrderCode(key: String) = sizeSelectionOrder.getOrElse(key, 100)
sizes.toList.sort((a,b) => getOrderCode(a.sizeName) < getOrderCode(b.sizeName))(0).url
}

def getSmallSizeUrl: String = {
Expand Down

0 comments on commit ac43f1d

Please sign in to comment.