From 2b5348ce2a7703a6c958b52a6e1acc7119fa75b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Tue, 24 Oct 2023 16:28:48 +0200 Subject: [PATCH] rename param size to widthPixels more explicit --- .../ch/srg/dataProvider/integrationlayer/data/ImageUrl.kt | 2 +- .../request/image/DefaultImageUrlDecorator.kt | 6 +++--- .../request/image/IlHostImageUrlDecorator.kt | 4 ++-- .../request/image/ScaleWidthImageUrlDecorator.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ImageUrl.kt b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ImageUrl.kt index 242824c..c9dd206 100644 --- a/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ImageUrl.kt +++ b/data/src/main/java/ch/srg/dataProvider/integrationlayer/data/ImageUrl.kt @@ -39,5 +39,5 @@ data class ImageUrl( } interface ImageUrlDecorator { - fun decorate(source: String, size: Int): String + fun decorate(source: String, widthPixels: Int): String } diff --git a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/DefaultImageUrlDecorator.kt b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/DefaultImageUrlDecorator.kt index 2bc1701..1a442bf 100644 --- a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/DefaultImageUrlDecorator.kt +++ b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/DefaultImageUrlDecorator.kt @@ -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) } } } diff --git a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/IlHostImageUrlDecorator.kt b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/IlHostImageUrlDecorator.kt index e969db2..aff48cf 100644 --- a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/IlHostImageUrlDecorator.kt +++ b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/IlHostImageUrlDecorator.kt @@ -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) diff --git a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/ScaleWidthImageUrlDecorator.kt b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/ScaleWidthImageUrlDecorator.kt index f0b34ff..658ad93 100644 --- a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/ScaleWidthImageUrlDecorator.kt +++ b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/request/image/ScaleWidthImageUrlDecorator.kt @@ -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() }