PhotoPickerSelectionParams.Builder
public
static
final
class
PhotoPickerSelectionParams.Builder
extends Object
| java.lang.Object | |
| ↳ | android.widget.photopicker.PhotoPickerSelectionParams.Builder |
A builder class used to construct and validate an immutable
PhotoPickerSelectionParams object.
Summary
Public constructors | |
|---|---|
Builder()
|
|
Public methods | |
|---|---|
PhotoPickerSelectionParams
|
build()
Builds a new immutable |
PhotoPickerSelectionParams.Builder
|
clearMaxMediaItemResolution()
Clears the maximum media item resolution constraint. |
PhotoPickerSelectionParams.Builder
|
clearMaxMediaItemSize()
Clears the maximum media item size constraint. |
PhotoPickerSelectionParams.Builder
|
clearMaxSelectionBatchSize()
Clears the maximum cumulative selection size constraint. |
PhotoPickerSelectionParams.Builder
|
clearMaxVideoDuration()
Clears the maximum video duration constraint. |
PhotoPickerSelectionParams.Builder
|
clearMimeTypes()
Clears the MIME type constraint. |
PhotoPickerSelectionParams.Builder
|
clearMinMediaItemResolution()
Clears the minimum media item resolution constraint. |
PhotoPickerSelectionParams.Builder
|
clearMinVideoDuration()
Clears the minimum video duration constraint. |
PhotoPickerSelectionParams.Builder
|
setMaxMediaItemResolutionInPixels(long maxMediaItemResolutionInPixels)
Sets the maximum allowed resolution constraint for a media item to be selectable. |
PhotoPickerSelectionParams.Builder
|
setMaxMediaItemSizeInBytes(long maxMediaItemSizeInBytes)
Sets the maximum allowed size, in bytes, for any individual media item to be selectable. |
PhotoPickerSelectionParams.Builder
|
setMaxSelectionBatchSizeInBytes(long maxSelectionBatchSizeInBytes)
Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items. |
PhotoPickerSelectionParams.Builder
|
setMaxVideoDuration(Duration maxVideoDuration)
Sets the maximum allowed duration for a video media item to be selectable. |
PhotoPickerSelectionParams.Builder
|
setMimeTypes(List<String> mimeTypes)
Sets the list of MIME types that are allowed for selection. |
PhotoPickerSelectionParams.Builder
|
setMinMediaItemResolutionInPixels(long minMediaItemResolutionInPixels)
Sets the minimum allowed resolution constraint for a media item to be selectable. |
PhotoPickerSelectionParams.Builder
|
setMinVideoDuration(Duration minVideoDuration)
Sets the minimum allowed duration for a video media item to be selectable. |
Inherited methods | |
|---|---|
Public constructors
Public methods
build
public PhotoPickerSelectionParams build ()
Builds a new immutable PhotoPickerSelectionParams object.
| Returns | |
|---|---|
PhotoPickerSelectionParams |
A new PhotoPickerSelectionParams object with the configured properties.
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if any of the minimum values are greater than their corresponding maximum values. |
clearMaxMediaItemResolution
public PhotoPickerSelectionParams.Builder clearMaxMediaItemResolution ()
Clears the maximum media item resolution constraint.
On calling this, the PhotoPicker will not enforce an upper limit on the total resolution of individual media items.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMaxMediaItemSize
public PhotoPickerSelectionParams.Builder clearMaxMediaItemSize ()
Clears the maximum media item size constraint.
On calling this, the PhotoPicker will not enforce an upper limit on the size of individual media items.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMaxSelectionBatchSize
public PhotoPickerSelectionParams.Builder clearMaxSelectionBatchSize ()
Clears the maximum cumulative selection size constraint.
On calling this, the PhotoPicker will not enforce a limit on the total aggregate size of the selected media items in a single session.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMaxVideoDuration
public PhotoPickerSelectionParams.Builder clearMaxVideoDuration ()
Clears the maximum video duration constraint.
On calling this, the PhotoPicker will not enforce an upper limit on the duration of video media items.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMimeTypes
public PhotoPickerSelectionParams.Builder clearMimeTypes ()
Clears the MIME type constraint.
On calling this, the builder will revert to its default state of allowing all supported media MIME types (images and videos) for selection.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMinMediaItemResolution
public PhotoPickerSelectionParams.Builder clearMinMediaItemResolution ()
Clears the minimum media item resolution constraint.
On calling this, the PhotoPicker will not enforce a lower limit on the total resolution of individual media items.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
clearMinVideoDuration
public PhotoPickerSelectionParams.Builder clearMinVideoDuration ()
Clears the minimum video duration constraint.
On calling this, the PhotoPicker will not enforce a lower limit on the duration of video media items.
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
See also:
setMaxMediaItemResolutionInPixels
public PhotoPickerSelectionParams.Builder setMaxMediaItemResolutionInPixels (long maxMediaItemResolutionInPixels)
Sets the maximum allowed resolution constraint for a media item to be selectable.
Items exceeding the provided resolution will be disabled for selection.
The maximum resolution should not be less than the minimum resolution, or an
exception will be thrown during the build() process.
If it is not set, no maximum resolution constraint will be enforced on the media items that the user can select.
| Parameters | |
|---|---|
maxMediaItemResolutionInPixels |
long: The maximum media item resolution in pixels |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if maxMediaItemResolutionInPixels is negative or
zero |
setMaxMediaItemSizeInBytes
public PhotoPickerSelectionParams.Builder setMaxMediaItemSizeInBytes (long maxMediaItemSizeInBytes)
Sets the maximum allowed size, in bytes, for any individual media item to be selectable.
The calling application can set this to limit the size of media returned by the PhotoPicker. Items exceeding this limit will be disabled for selection.
If it is not set, no maximum size constraint will be enforced on the media items that the user can select.
| Parameters | |
|---|---|
maxMediaItemSizeInBytes |
long: The maximum size in bytes. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if maxMediaItemSizeInBytes is negative or zero |
setMaxSelectionBatchSizeInBytes
public PhotoPickerSelectionParams.Builder setMaxSelectionBatchSizeInBytes (long maxSelectionBatchSizeInBytes)
Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items.
This limits the total aggregate size of the media selected by the user. If a new selection causes the total size to exceed this limit, the user will be alerted that they have reached the maximum selection size limit and must deselect items before proceeding.
If it is not set, no collective batch size constraint will be enforced on media items that the user can select.
| Parameters | |
|---|---|
maxSelectionBatchSizeInBytes |
long: The maximum batch size in bytes. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if maxSelectionBatchSizeInBytes is negative or
zero |
setMaxVideoDuration
public PhotoPickerSelectionParams.Builder setMaxVideoDuration (Duration maxVideoDuration)
Sets the maximum allowed duration for a video media item to be selectable.
Videos exceeding this duration will be disabled for selection.
The maximum duration should not be less than minimum duration, or an
exception will be thrown during the build() process.
If it is not set, no maximum video duration constraint will be enforced on the videos that the user can select.
| Parameters | |
|---|---|
maxVideoDuration |
Duration: The maximum video duration.
This value cannot be null. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if maxVideoDuration is null, negative
or zero |
setMimeTypes
public PhotoPickerSelectionParams.Builder setMimeTypes (List<String> mimeTypes)
Sets the list of MIME types that are allowed for selection.
Media items that violate this constraint will be disabled for selection.
This parameter is different from the MIME types which can be specified in android.content.Intent.setType(String) extra or Intent.EXTRA_MIME_TYPES, when those are used to launch the photo picker,
they will filter out any media items which has a MIME type not added to them. While the
MIME Types defined by this API will still exist in photo picker media grid, but disabled
from selection.
Filter media items using the MIME Types defined in android.content.Intent.setType(String) extra or Intent.EXTRA_MIME_TYPES will happen first, before disabling the media
items based on the MIME Types passed to this API.
Callers must indicate the acceptable document MIME types. For example, to select
photos, use image/*.
If it is not set, no MIME type constraint will be enforced on the media items the user can select.
| Parameters | |
|---|---|
mimeTypes |
List: The list of allowed MIME types.
This value cannot be null. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if mimeTypes is null, empty, or contains
non-media types (types not starting with "image/" or
"video/"). |
setMinMediaItemResolutionInPixels
public PhotoPickerSelectionParams.Builder setMinMediaItemResolutionInPixels (long minMediaItemResolutionInPixels)
Sets the minimum allowed resolution constraint for a media item to be selectable.
Media items with a resolution lower than the provided threshold will be disabled for selection.
The minimum resolution should not be greater than the maximum resolution, or an
exception will be thrown during the build() process.
If it is not set, no minimum resolution constraint will be enforced on the media items that the user can select.
| Parameters | |
|---|---|
minMediaItemResolutionInPixels |
long: The minimum allowed resolution in total pixels. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if minMediaItemResolutionInPixels is negative. |
setMinVideoDuration
public PhotoPickerSelectionParams.Builder setMinVideoDuration (Duration minVideoDuration)
Sets the minimum allowed duration for a video media item to be selectable.
Videos shorter than this duration will be disabled for selection.
The maximum duration should not be less than minimum duration, or an
exception will be thrown during the build() process.
If it is not set, no minimum video duration constraint will be enforced on the videos that the user can select.
| Parameters | |
|---|---|
minVideoDuration |
Duration: The minimum video duration.
This value cannot be null. |
| Returns | |
|---|---|
PhotoPickerSelectionParams.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if minVideoDuration is negative |