Register now for Android Dev Summit 2019!

ImageReference.Builder

public static final class ImageReference.Builder
extends Object

java.lang.Object
   ↳ androidx.car.cluster.navigation.ImageReference.Builder


Builder for creating an ImageReference.

Summary

Public constructors

ImageReference.Builder()

Public methods

ImageReference build()

Returns a ImageReference built with the provided information.

ImageReference.Builder setContentUri(String contentUri)

Sets a 'content://' style URI

ImageReference.Builder setIsTintable(boolean isTintable)

Sets whether this image is "tintable" or not.

ImageReference.Builder setOriginalSize(int width, int height)

Sets the aspect ratio of this image, expressed as with and height sizes.

Inherited methods

Public constructors

ImageReference.Builder

public ImageReference.Builder ()

Public methods

build

public ImageReference build ()

Returns a ImageReference built with the provided information. Calling setContentUri(String) and setOriginalSize(int, int) before calling this method is mandatory.

Returns
ImageReference an ImageReference instance

Throws
NullPointerException if content URI is not provided.
IllegalArgumentException if original size is not set.

setContentUri

public ImageReference.Builder setContentUri (String contentUri)

Sets a 'content://' style URI

Parameters
contentUri String

Returns
ImageReference.Builder this object for chaining

Throws
NullPointerException if the provided contentUri is null
IllegalArgumentException if the provided contentUri doesn't start with 'content://'.

setIsTintable

public ImageReference.Builder setIsTintable (boolean isTintable)

Sets whether this image is "tintable" or not. An image is "tintable" when all its content is defined in its alpha-channel, designed to be colorized (e.g. using PorterDuff.Mode.SRC_ATOP image composition). If this method is not used, images will be non "tintable" by default.

Parameters
isTintable boolean

Returns
ImageReference.Builder this object for chaining

setOriginalSize

public ImageReference.Builder setOriginalSize (int width, 
                int height)

Sets the aspect ratio of this image, expressed as with and height sizes. Both dimensions must be greater than 0.

Parameters
width int

Value is between 1 and 2147483647 inclusive.

height int

Value is between 1 and 2147483647 inclusive.

Returns
ImageReference.Builder this object for chaining

Throws
IllegalArgumentException if any of the dimensions is not positive.