Permalink
Browse files

Accommodate new Flickr picture sizes

  • Loading branch information...
1 parent a6d0aed commit ac43f1da47be1f1b32bb81c9563d7ffc4700b425 @dcbriccetti committed Aug 21, 2010
Showing with 11 additions and 8 deletions.
  1. +1 −1 pom.xml
  2. +10 −7 src/main/scala/birdshow/model/flickr/PictureIdAndSizes.scala
View
@@ -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>
@@ -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 = {

0 comments on commit ac43f1d

Please sign in to comment.