Package com.cloudinary.android
Class ResponsiveUrl
java.lang.Object
com.cloudinary.android.ResponsiveUrl
public class ResponsiveUrl
extends java.lang.Object
This class is used to generate view-size aware cloudinary Urls. It takes any
View and
a Url as input and returns a modified Url with the width/height transformation
included, according to the chosen parameters.
Note: When using this class, it's preferable to not include any cropping/scaling/dpr
transformation in the base Url used. This can lead to unexpected results.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceResponsiveUrl.CallbackCallback to send togenerate(Url, View, Callback)static classResponsiveUrl.PresetReady made presets for common responsive use cases -
Method Summary
Modifier and Type Method Description com.cloudinary.UrlbuildUrl(com.cloudinary.Url baseUrl, int width, int height)Construct the final url with the dimensions included as the last transformation in the url.voidgenerate(com.cloudinary.Url baseUrl, android.view.View view, ResponsiveUrl.Callback callback)Generate the modified url.voidgenerate(java.lang.String publicId, android.view.View view, ResponsiveUrl.Callback callback)Generate the modified url.ResponsiveUrlmaxDimension(int maxDimension)Limit the minimum allowed dimension, in pixels.ResponsiveUrlminDimension(int minDimension)Limit the minimum allowed dimension, in pixels.ResponsiveUrlstepSize(int stepSize)Step size i pixels.
-
Method Details
-
stepSize
Step size i pixels. This is used to limit the number of generated transformations. The actual width/height parameter in the constructed url will always be a multiplication of step size and not the exact view width/height. For example, when using `width` with `stepSize` 100 on a view with width between 301 and 400 will render as `w_400` in the url.- Parameters:
stepSize- The step size to use, in pixels.- Returns:
- Itself for chaining.
-
maxDimension
Limit the minimum allowed dimension, in pixels. If the actual view width or height are larger than the value chosen here, this value will be used instead. This is useful to limit the total number of generated transformations.- Parameters:
maxDimension- The highest allowed dimension, in pixels.- Returns:
- itself for chaining.
-
minDimension
Limit the minimum allowed dimension, in pixels. If the actual view width or height are smaller than the value chosen here, this value will be used instead. This is useful to limit the total number of generated transformations.- Parameters:
minDimension- The smallest allowed dimension, in pixels.- Returns:
- itself for chaining.
-
generate
public void generate(java.lang.String publicId, android.view.View view, ResponsiveUrl.Callback callback)Generate the modified url.- Parameters:
publicId- The public id of the cloudinary resourceview- The view to adapt the resource dimensions to.callback- Callback to called when the modified Url is ready.
-
generate
public void generate(com.cloudinary.Url baseUrl, android.view.View view, ResponsiveUrl.Callback callback)Generate the modified url.- Parameters:
baseUrl- A url to be used as a base to the responsive transformation. This url can contain any configurations and transformations. The generated responsive transformation will be chained as the last transformation in the url. Important: When generating using a base url, it's preferable to not include any cropping/scaling in the original transformations.view- The view to adapt the resource dimensions to.callback- Callback to called when the modified Url is ready.
-
buildUrl
public com.cloudinary.Url buildUrl(com.cloudinary.Url baseUrl, int width, int height)Construct the final url with the dimensions included as the last transformation in the url.- Parameters:
baseUrl- The base cloudinary Url to chain the transformation to.width- The width to adapt the image width to.height- The height to adapt the image height to.- Returns:
- The url with the responsive transformation.
-