Skip to content

Commit

Permalink
rename param size to widthPixels more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Oct 24, 2023
1 parent 1e1822f commit 2b5348c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ data class ImageUrl(
}

interface ImageUrlDecorator {
fun decorate(source: String, size: Int): String
fun decorate(source: String, widthPixels: Int): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import ch.srg.dataProvider.integrationlayer.request.IlHost
class DefaultImageUrlDecorator(ilHost: IlHost = IlHost.PROD) : ImageUrlDecorator {
private val ilHostImageUrlDecorator = IlHostImageUrlDecorator(ilHost)

override fun decorate(imageUrl: String, size: Int): String {
override fun decorate(imageUrl: String, widthPixels: Int): String {
// FIXME https://github.com/SRGSSR/srgdataprovider-apple/issues/47 once RTS image service is well connected to Il Play image service.
return if (imageUrl.contains("rts.ch") && imageUrl.contains(".image")) {
ScaleWidthImageUrlDecorator.decorate(imageUrl, size)
ScaleWidthImageUrlDecorator.decorate(imageUrl, widthPixels)
} else {
ilHostImageUrlDecorator.decorate(imageUrl, size)
ilHostImageUrlDecorator.decorate(imageUrl, widthPixels)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class IlHostImageUrlDecorator(ilHost: IlHost) : ImageUrlDecorator {
imageServiceUri = ilHost.hostUri.buildUpon().appendEncodedPath(IMAGES_SEGMENT).build()
}

override fun decorate(source: String, size: Int): String {
override fun decorate(source: String, widthPixels: Int): String {
// Il image service only support a limited image size!
val imageWidth = ImageWidth.getFromPixels(size)
val imageWidth = ImageWidth.getFromPixels(widthPixels)
return imageServiceUri.buildUpon()
.appendQueryParameter(PARAM_IMAGE_URL, source)
.appendQueryParameter(PARAM_FORMAT, FORMAT_WEBP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ object ScaleWidthImageUrlDecorator : ImageUrlDecorator {
private const val Scale = "scale"
private const val Width = "width"

override fun decorate(source: String, size: Int): String {
override fun decorate(source: String, widthPixels: Int): String {
return Uri.parse(source).buildUpon()
.appendPath(Scale)
.appendPath(Width)
.appendPath(size.toString())
.appendPath(widthPixels.toString())
.build()
.toString()
}
Expand Down

0 comments on commit 2b5348c

Please sign in to comment.