RetryPolicy.RetryConfig.Builder


@ExperimentalRetryPolicy
class RetryPolicy.RetryConfig.Builder


A builder class for creating and customizing RetryConfig objects.

While predefined configs like DEFAULT_DELAY_RETRY are recommended for typical recovery scenarios, this builder allows for fine-tuned control when specific requirements necessitate a different approach.

Summary

Public constructors

Public functions

RetryPolicy.RetryConfig

Builds the customized RetryConfig object.

RetryPolicy.RetryConfig.Builder
setRetryDelayInMillis(timeoutInMillis: @IntRange(from = 100, to = 2000) Long)

Sets the retry delay in milliseconds.

RetryPolicy.RetryConfig.Builder
setShouldRetry(shouldRetry: Boolean)

Specifies whether a retry should be attempted.

Public constructors

Builder

Added in 1.4.0
Builder()

Public functions

build

Added in 1.4.0
fun build(): RetryPolicy.RetryConfig

Builds the customized RetryConfig object.

Returns
RetryPolicy.RetryConfig

The configured RetryConfig.

setRetryDelayInMillis

Added in 1.4.0
fun setRetryDelayInMillis(timeoutInMillis: @IntRange(from = 100, to = 2000) Long): RetryPolicy.RetryConfig.Builder

Sets the retry delay in milliseconds.

If set, the initialization will be retried after the specified delay. For optimal results, the delay should be within the range of 100 to 2000 milliseconds. This aligns with lab testing, which suggests this range provides sufficient recovery time for most common camera issues while minimizing latency.

Parameters
timeoutInMillis: @IntRange(from = 100, to = 2000) Long

The delay in milliseconds.

Returns
RetryPolicy.RetryConfig.Builder

this for method chaining.

setShouldRetry

Added in 1.4.0
fun setShouldRetry(shouldRetry: Boolean): RetryPolicy.RetryConfig.Builder

Specifies whether a retry should be attempted.

Parameters
shouldRetry: Boolean

If true (the default), initialization will be retried. If false, initialization will not be retried.

Returns
RetryPolicy.RetryConfig.Builder

this for method chaining.