Class Animation

java.lang.Object
ch.hevs.kart.utils.Animation

public class Animation extends Object

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 Classes
    Modifier and Type
    Class
    Description
    static 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 Type
    Method
    Description
    Builder(Kart kart)
    Returns a new Animation.Builder instance that can be used to build custom LED/Kart animations.
    void
    Cancels the animation.
    boolean
    Returns true if the animation is actually running and false if not.
    void
    Starts the animation and executes the animation in a loop infinitely.
    void
    run()
    Starts the animation and executes the animation exactly once.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static Animation.Builder Builder(Kart kart)

      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.