MultiLightEffect


public final class MultiLightEffect
extends Object implements Parcelable

java.lang.Object
   ↳ android.hardware.lights.MultiLightEffect


Models an effect that will be shown in one or more lights.

Effects are comprised of [light, ColorSequence] pairs defining how each light should change over time along with some extra configuration values:

  • Iterations: the number of times the effect will be played back to back.
  • Preemptive: whether this effect should preempt any previously playing state or if it should be played after the current effect finishes.

A MultiLightEffect is treated as a unit with a given start time and an implicit duration:

  • Start time: all lights sequences in the effect start at the same time, regardless of having a initial state or not.
  • Duration: the duration of the effect is the duration of the longest sequence it contains. If a light sequence in the effect is shorter than the effect duration, the light will remain as a solid color until the end of the effect.

ColorSequences in the effect could have initial states (delay=0) for their corresponding lights, which has special implications when the effect will be played as a continuation of another effect (effects with preemptive=false and/or effects with initial states and more than one iteration).

The initial state will be applied only if the effect is set to preemptive and it is the first iteration of the effect. The system ignores the initial state in subsequent iterations or in effects with preemptive=false to allow the light to transition smoothly and avoid flicks.

Summary

Nested classes

class MultiLightEffect.Builder

Builder for MultiLightEffect objects. 

Inherited constants

Fields

public static final Creator<MultiLightEffect> CREATOR

Implement the Parcelable interface

Public methods

int describeContents()

Implement the Parcelable interface

int getIterations()

Returns the number of times this effect will be played in a loop.

Map<IntegerColorSequence> getSequences()

Returns the color sequences defined in the light effect for each of the lights.

boolean isPreemptive()

Returns whether this effect will cancel any previously playing effect.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Implement the Parcelable interface

Inherited methods

Fields

CREATOR

public static final Creator<MultiLightEffect> CREATOR

Implement the Parcelable interface

Public methods

describeContents

public int describeContents ()

Implement the Parcelable interface

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

getIterations

public int getIterations ()

Returns the number of times this effect will be played in a loop. Defaults to 1.

Returns
int the number of iterations to play.

getSequences

public Map<IntegerColorSequence> getSequences ()

Returns the color sequences defined in the light effect for each of the lights.

The key for the returned map corresponds to the lightId (see Light.getId()) of the light that will play the color sequence represented by the value.

Returns
Map<IntegerColorSequence> the Map of lightIds to the color sequences that will be played for the effect.
This value cannot be null.

isPreemptive

public boolean isPreemptive ()

Returns whether this effect will cancel any previously playing effect.

Returns
boolean true if this effect applies immediately, false otherwise.

toString

public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

Implement the Parcelable interface

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following: