SelectionParams.Builder


@RequiresApi(value = 26)
public final class SelectionParams.Builder


A builder for constructing SelectionParams instances.

Summary

Public constructors

Public methods

final @NonNull SelectionParams

Builds a new immutable SelectionParams object.

final @NonNull SelectionParams.Builder

Clears the maximum allowed resolution limit for media items.

final @NonNull SelectionParams.Builder

Clears the maximum allowed size limit for individual media items.

final @NonNull SelectionParams.Builder

Clears the maximum allowed cumulative batch size limit.

final @NonNull SelectionParams.Builder

Clears the maximum allowed duration limit for video media items.

final @NonNull SelectionParams.Builder

Clears the allowed mime types selection constraint.

final @NonNull SelectionParams.Builder

Clears the minimum allowed resolution limit for media items.

final @NonNull SelectionParams.Builder

Clears the minimum allowed duration limit for video media items.

final @NonNull SelectionParams.Builder
setMaxMediaItemResolutionInPixels(long maxMediaItemResolutionInPixels)

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

final @NonNull SelectionParams.Builder
setMaxMediaItemSizeInBytes(long maxMediaItemSizeInBytes)

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

final @NonNull SelectionParams.Builder
setMaxSelectionBatchSizeInBytes(long maxSelectionBatchSizeInBytes)

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

final @NonNull SelectionParams.Builder

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

final @NonNull SelectionParams.Builder

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

final @NonNull SelectionParams.Builder
setMinMediaItemResolutionInPixels(long minMediaItemResolutionInPixels)

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

final @NonNull SelectionParams.Builder

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

Public constructors

Builder

Added in 1.0.0-alpha03
public Builder()

Public methods

build

Added in 1.0.0-alpha03
public final @NonNull SelectionParams build()

Builds a new immutable SelectionParams object.

Returns
@NonNull 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
public final @NonNull SelectionParams.Builder clearMaxMediaItemResolution()

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
@NonNull SelectionParams.Builder

This builder.

clearMaxMediaItemSize

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMaxMediaItemSize()

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
@NonNull SelectionParams.Builder

This builder.

clearMaxSelectionBatchSize

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMaxSelectionBatchSize()

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
@NonNull SelectionParams.Builder

This builder.

clearMaxVideoDuration

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMaxVideoDuration()

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
@NonNull SelectionParams.Builder

This builder.

clearMimeTypes

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMimeTypes()

Clears the allowed mime types selection constraint.

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

Returns
@NonNull SelectionParams.Builder

This builder.

clearMinMediaItemResolution

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMinMediaItemResolution()

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
@NonNull SelectionParams.Builder

This builder.

clearMinVideoDuration

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder clearMinVideoDuration()

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
@NonNull SelectionParams.Builder

This builder.

setMaxMediaItemResolutionInPixels

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMaxMediaItemResolutionInPixels(long maxMediaItemResolutionInPixels)

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
long maxMediaItemResolutionInPixels

The maximum media item resolution in total pixels.

Returns
@NonNull SelectionParams.Builder

This builder.

setMaxMediaItemSizeInBytes

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMaxMediaItemSizeInBytes(long maxMediaItemSizeInBytes)

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
long maxMediaItemSizeInBytes

The maximum size in bytes.

Returns
@NonNull SelectionParams.Builder

This builder.

setMaxSelectionBatchSizeInBytes

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMaxSelectionBatchSizeInBytes(long maxSelectionBatchSizeInBytes)

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
long maxSelectionBatchSizeInBytes

The maximum batch size in bytes.

Returns
@NonNull SelectionParams.Builder

This builder.

setMaxVideoDuration

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMaxVideoDuration(@NonNull Duration maxVideoDuration)

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
@NonNull Duration maxVideoDuration

The maximum video duration.

Returns
@NonNull SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

if maxVideoDuration is not positive.

setMimeTypes

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMimeTypes(@NonNull List<@NonNull String> mimeTypes)

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
@NonNull List<@NonNull String> mimeTypes

The list of allowed mime types.

Returns
@NonNull SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

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

setMinMediaItemResolutionInPixels

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMinMediaItemResolutionInPixels(long minMediaItemResolutionInPixels)

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
long minMediaItemResolutionInPixels

The minimum allowed resolution in total pixels.

Returns
@NonNull SelectionParams.Builder

This builder.

setMinVideoDuration

Added in 1.0.0-alpha03
public final @NonNull SelectionParams.Builder setMinVideoDuration(@NonNull Duration minVideoDuration)

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
@NonNull Duration minVideoDuration

The minimum video duration.

Returns
@NonNull SelectionParams.Builder

This builder.

Throws
IllegalArgumentException

if minVideoDuration is not positive.