Package 

Class StopWatch


  • 
    public class StopWatch
    
                        

    A simple stopwatch to keep a correct and updated record of the running duration of processes.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface StopWatch.TickListener
    • Method Summary

      Modifier and Type Method Description
      void start() Starts the stopwatch.
      void stop() Stops the stopwatch, capturing the ending time
      void reset() Resets the current time for the stopWatch
      void overrideCurrentTime(long time) Forcefully sets the current time for the stopwatch.
      long getTime() Retrieves the current time for the stopwatch.
      int getTimeInt() Retrieves the current time for the stopwatch.
      void setTickListener(StopWatch.TickListener listener) Sets the listener to be notified for each time update (tick)
      boolean isRunning() Determines if the stopwatch is currently running
      int getTickDelay() Retrieves the approximate duration between time updates.
      float getSpeedMultiplier() Retrieves the current multiplier used for the current time calculations.
      void setTickDelay(int milliSeconds) Sets the approximate duration between time updates.
      void setSpeedMultiplier(float multiplier) Sets the multiplier to use when calculating the passed duration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StopWatch

        StopWatch()
      • StopWatch

        StopWatch(boolean processOnStartingThread)
        Parameters:
        processOnStartingThread - True if the repeating process should be handled on the same thread that created the Repeater
      • StopWatch

        StopWatch(Handler handler)
        Parameters:
        handler - The Handler to use for the repeating process
    • Method Detail

      • start

         void start()

        Starts the stopwatch. This will continue from where we last left off, if you need to start from 0 call reset first.

      • stop

         void stop()

        Stops the stopwatch, capturing the ending time

      • reset

         void reset()

        Resets the current time for the stopWatch

      • overrideCurrentTime

         void overrideCurrentTime(long time)

        Forcefully sets the current time for the stopwatch.

        Parameters:
        time - The new stopwatch time in milliseconds
      • getTime

         long getTime()

        Retrieves the current time for the stopwatch. If the stopwatch is stopped then the ending time will be returned.

      • getTimeInt

         int getTimeInt()

        Retrieves the current time for the stopwatch. If the stopwatch is stopped then the ending time will be returned.

      • isRunning

         boolean isRunning()

        Determines if the stopwatch is currently running

      • getTickDelay

         int getTickDelay()

        Retrieves the approximate duration between time updates.

      • getSpeedMultiplier

         float getSpeedMultiplier()

        Retrieves the current multiplier used for the current time calculations. NOTE: the default is 1

      • setTickDelay

         void setTickDelay(int milliSeconds)

        Sets the approximate duration between time updates.

        Parameters:
        milliSeconds - The approximate duration between time updates [default: ]
      • setSpeedMultiplier

         void setSpeedMultiplier(float multiplier)

        Sets the multiplier to use when calculating the passed duration. This won't affect the tick delay setTickDelay but will change the output for the current time.

        Parameters:
        multiplier - The amount to multiply the duration between each tick by