SelectionParams.Builder


@RequiresApi(value = 26)
class SelectionParams.Builder


A builder for constructing SelectionParams instances.

Summary

Public constructors

Public functions

SelectionParams

Builds a new immutable SelectionParams object.

SelectionParams.Builder

Clears the maximum allowed resolution limit for media items.

SelectionParams.Builder

Clears the maximum allowed size limit for individual media items.

SelectionParams.Builder

Clears the maximum allowed cumulative batch size limit.

SelectionParams.Builder

Clears the maximum allowed duration limit for video media items.

SelectionParams.Builder

Clears the allowed mime types selection constraint.

SelectionParams.Builder

Clears the minimum allowed resolution limit for media items.

SelectionParams.Builder

Clears the minimum allowed duration limit for video media items.

SelectionParams.Builder
setMaxMediaItemResolutionInPixels(maxMediaItemResolutionInPixels: Long)

Sets the maximum allowed resolution constraint for a media item to be selectable.

SelectionParams.Builder
setMaxMediaItemSizeInBytes(maxMediaItemSizeInBytes: Long)

Sets the maximum allowed size, in bytes, for any individual media item to be selectable.

SelectionParams.Builder
setMaxSelectionBatchSizeInBytes(maxSelectionBatchSizeInBytes: Long)

Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items.

SelectionParams.Builder
setMaxVideoDuration(maxVideoDuration: Duration)

Sets the maximum allowed duration for a video media item to be selectable.

SelectionParams.Builder
setMimeTypes(mimeTypes: List<String>)

Sets the list of mime types that are allowed for selection.

SelectionParams.Builder
setMinMediaItemResolutionInPixels(minMediaItemResolutionInPixels: Long)

Sets the minimum allowed resolution constraint for a media item to be selectable.

SelectionParams.Builder
setMinVideoDuration(minVideoDuration: Duration)

Sets the minimum allowed duration for a video media item to be selectable.

Public constructors

Builder

Added in 1.0.0-alpha03
Builder()

Public functions

build

Added in 1.0.0-alpha03
fun build(): SelectionParams

Builds a new immutable SelectionParams object.

Returns
SelectionParams

The newly constructed SelectionParams.

Throws
IllegalArgumentException

if minVideoDuration is greater than maxVideoDuration, or minMediaItemResolutionInPixels is greater than maxMediaItemResolutionInPixels.

clearMaxMediaItemResolution

Added in 1.0.0-alpha03
fun clearMaxMediaItemResolution(): SelectionParams.Builder

Clears the maximum allowed resolution limit for media items.

On calling this, the PhotoPicker will not enforce an upper limit on the resolution of media items.

Returns
SelectionParams.Builder

This builder.

clearMaxMediaItemSize

Added in 1.0.0-alpha03
fun clearMaxMediaItemSize(): SelectionParams.Builder

Clears the maximum allowed size limit for individual media items.

On calling this, the PhotoPicker will not enforce an upper limit on the size of individual media items.

Returns
SelectionParams.Builder

This builder.

clearMaxSelectionBatchSize

Added in 1.0.0-alpha03
fun clearMaxSelectionBatchSize(): SelectionParams.Builder

Clears the maximum allowed cumulative batch size limit.

On calling this, the PhotoPicker will not enforce an upper limit on the cumulative size of selected media items.

Returns
SelectionParams.Builder

This builder.

clearMaxVideoDuration

Added in 1.0.0-alpha03
fun clearMaxVideoDuration(): SelectionParams.Builder

Clears the maximum allowed duration limit for video media items.

On calling this, the PhotoPicker will not enforce an upper limit on the duration of video media items.

Returns
SelectionParams.Builder

This builder.

clearMimeTypes

Added in 1.0.0-alpha03
fun clearMimeTypes(): SelectionParams.Builder

Clears the allowed mime types selection constraint.

On calling this, the PhotoPicker will not enforce allowed mime type constraints for selection.

Returns
SelectionParams.Builder

This builder.

clearMinMediaItemResolution

Added in 1.0.0-alpha03
fun clearMinMediaItemResolution(): SelectionParams.Builder

Clears the minimum allowed resolution limit for media items.

On calling this, the PhotoPicker will not enforce a lower limit on the resolution of media items.

Returns
SelectionParams.Builder

This builder.

clearMinVideoDuration

Added in 1.0.0-alpha03
fun clearMinVideoDuration(): SelectionParams.Builder

Clears the minimum allowed duration limit for video media items.

On calling this, the PhotoPicker will not enforce a lower limit on the duration of video media items.

Returns
SelectionParams.Builder

This builder.

setMaxMediaItemResolutionInPixels

Added in 1.0.0-alpha03
fun setMaxMediaItemResolutionInPixels(maxMediaItemResolutionInPixels: Long): SelectionParams.Builder

Sets the maximum allowed resolution constraint for a media item to be selectable.

Media items with total resolution (width * height) exceeding this limit will be disabled and cannot be selected.

If the maximum resolution is not set by the caller app using setMaxMediaItemResolutionInPixels, there will be no restriction on the maximum resolution.

Parameters
maxMediaItemResolutionInPixels: Long

The maximum media item resolution in total pixels.

Returns
SelectionParams.Builder

This builder.

setMaxMediaItemSizeInBytes

Added in 1.0.0-alpha03
fun setMaxMediaItemSizeInBytes(maxMediaItemSizeInBytes: Long): SelectionParams.Builder

Sets the maximum allowed size, in bytes, for any individual media item to be selectable.

Media items exceeding this size will be disabled and cannot be selected.

If the maximum media item size is not set by the caller app using setMaxMediaItemSizeInBytes, there will be no restriction on the maximum media item size.

Parameters
maxMediaItemSizeInBytes: Long

The maximum size in bytes.

Returns
SelectionParams.Builder

This builder.

setMaxSelectionBatchSizeInBytes

Added in 1.0.0-alpha03
fun setMaxSelectionBatchSizeInBytes(maxSelectionBatchSizeInBytes: Long): SelectionParams.Builder

Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items.

This limits the aggregate size of all items selected in a single PhotoPicker session. If selecting an item causes the total cumulative size to exceed this limit, the user will be alerted that the maximum selection size has been reached and cannot add more items until existing selections are removed.

If the maximum selection batch size is not set by the caller app using setMaxSelectionBatchSizeInBytes, there will be no restriction on the cumulative size of selected media items.

Parameters
maxSelectionBatchSizeInBytes: Long

The maximum batch size in bytes.

Returns
SelectionParams.Builder

This builder.

setMaxVideoDuration

Added in 1.0.0-alpha03
fun setMaxVideoDuration(maxVideoDuration: Duration): SelectionParams.Builder

Sets the maximum allowed duration for a video media item to be selectable.

Video items exceeding this duration will be disabled and cannot be selected.

If the maximum video duration is not set by the caller app using setMaxVideoDuration, there will be no restriction on the maximum video duration.

Parameters
maxVideoDuration: Duration

The maximum video duration.

Returns
SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

if maxVideoDuration is not positive.

setMimeTypes

Added in 1.0.0-alpha03
fun setMimeTypes(mimeTypes: List<String>): SelectionParams.Builder

Sets the list of mime types that are allowed for selection.

Media items whose mime type is not in this list will be visible in the picker grid but disabled for selection.

If the allowed mime types are not set by the caller app using setMimeTypes, all items matching the requested media type filter will be selectable.

This constraint is distinct from the media type filter specified via androidx.photopicker.activity.PickVisualMediaRequest.Builder.setMediaType. The media type in the request determines which items are queried and displayed in the PhotoPicker grid in the first place, whereas setMimeTypes controls which displayed items are enabled for selection.

Parameters
mimeTypes: List<String>

The list of allowed mime types.

Returns
SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

if mimeTypes is empty or contains non-image/video mime types.

setMinMediaItemResolutionInPixels

Added in 1.0.0-alpha03
fun setMinMediaItemResolutionInPixels(minMediaItemResolutionInPixels: Long): SelectionParams.Builder

Sets the minimum allowed resolution constraint for a media item to be selectable.

Media items with total resolution (width * height) below this limit will be disabled and cannot be selected.

If the minimum resolution is not set by the caller app using setMinMediaItemResolutionInPixels, there will be no restriction on the minimum resolution.

Parameters
minMediaItemResolutionInPixels: Long

The minimum allowed resolution in total pixels.

Returns
SelectionParams.Builder

This builder.

setMinVideoDuration

Added in 1.0.0-alpha03
fun setMinVideoDuration(minVideoDuration: Duration): SelectionParams.Builder

Sets the minimum allowed duration for a video media item to be selectable.

Video items shorter than this duration will be disabled and cannot be selected.

If the minimum video duration is not set by the caller app using setMinVideoDuration, there will be no restriction on the minimum video duration.

Parameters
minVideoDuration: Duration

The minimum video duration.

Returns
SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

if minVideoDuration is not positive.