Class Animation
Support for simple animations that run in the background (without blocking the Android App's main thread).
This can become quite handy if you just need to blink a LED or set an output to a given value for a defined amount of time and then change it back.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder in order to construct animations comfortable.static class
The ExclusiveRunner class ensures that only exactly one animation is running at the same time in its context. -
Method Summary
Modifier and TypeMethodDescriptionstatic Animation.Builder
Returns a new Animation.Builder instance that can be used to build custom LED/Kart animations.void
cancel()
Cancels the animation.boolean
Returns true if the animation is actually running and false if not.void
loop()
Starts the animation and executes the animation in a loop infinitely.void
run()
Starts the animation and executes the animation exactly once.
-
Method Details
-
isRunning
public boolean isRunning()Returns true if the animation is actually running and false if not.
- Returns:
- True if running, false otherwise.
-
run
public void run()Starts the animation and executes the animation exactly once. If the animation is already running, the animation will be restarted from the beginning.
-
loop
public void loop()Starts the animation and executes the animation in a loop infinitely. If the animation is already running, the animation will be restarted from the beginning.
-
cancel
public void cancel()Cancels the animation. The animation is stopped and has to be restarted by using either the run() or the loop() method.
-
Builder
Returns a new Animation.Builder instance that can be used to build custom LED/Kart animations.
- Parameters:
kart
- Reference to the Kart instance that will be controlled by the animation.- Returns:
- A reference to the newly created Animation builder instance.
-