Builder
class Builder
| kotlin.Any | |
| ↳ | android.hardware.lights.MultiLightEffect.Builder |
Builder for MultiLightEffect objects.
Summary
| Public constructors | |
|---|---|
Builder() |
|
| Public methods | |
|---|---|
| MultiLightEffect.Builder |
addLightSequence(light: Light, colorSequence: ColorSequence)Adds a new light and its corresponding sequence to the effect. |
| MultiLightEffect |
build()Builds the light effect. |
| MultiLightEffect.Builder |
setIterations(iterations: Int)Number of times that the effect should be played in a loop. |
| MultiLightEffect.Builder |
setPreemptive(preemptive: Boolean)Sets whether this effect will preempt any previous effect / state currently active on the light. |
Public constructors
Builder
Builder()
Public methods
addLightSequence
fun addLightSequence(
light: Light,
colorSequence: ColorSequence
): MultiLightEffect.Builder
Adds a new light and its corresponding sequence to the effect.
| Parameters | |
|---|---|
light |
Light: the light that will play the sequence. This value cannot be null. |
colorSequence |
ColorSequence: the sequence of colors and their timing. This value cannot be null. |
| Return | |
|---|---|
MultiLightEffect.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the light does not support animations. |
build
fun build(): MultiLightEffect
Builds the light effect.
| Return | |
|---|---|
MultiLightEffect |
A MultiLightEffect with the configuration and sequences configured. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if no light-sequence pair has been provided. |
setIterations
fun setIterations(iterations: Int): MultiLightEffect.Builder
Number of times that the effect should be played in a loop.
By default, the builder configures this value to 1 for a single run of the effect.
A value of 0 indicates the effect should repeat indefinitely until a new effect or state is provided for the light or until the light is turned off.
If the effect has an initial state (delay = 0 for the first control point) the initial state will only be applied during the first iteration and all other iterations will ignore the initial value.
| Parameters | |
|---|---|
iterations |
Int: number of times the effect should be played. |
| Return | |
|---|---|
MultiLightEffect.Builder |
This value cannot be null. |
setPreemptive
fun setPreemptive(preemptive: Boolean): MultiLightEffect.Builder
Sets whether this effect will preempt any previous effect / state currently active on the light.
By default, the builder sets this value to true and the effect is preemptive.
When preemptive=false AND the previous light state is a:
When preemptive=true the effect is applied immediately regardless of previous state.
Even when the effect preempts an existing state, the effect may not necessarily provide an initial state and the first control point may be relatively far in the future. Applications can make use of these conditions to create a fading effect between the last known state of the light and the new effect.
When creating fading effects, the following applies:
The system has a maximum of one non-preemptive event in the queue per light session. If an effect A is playing and the application requests two non-preemptive events (B and C) before A is done playing, only C will be kept and played after A, and B will be discarded.
| Parameters | |
|---|---|
preemptive |
Boolean: true to play immediately or false wait for the previous effect to finish. |
| Return | |
|---|---|
MultiLightEffect.Builder |
This value cannot be null. |