public class StopWatch
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
StopWatch.TickListener |
protected class |
StopWatch.TickRunnable |
| Modifier and Type | Field and Description |
|---|---|
protected long |
currentTime |
protected static int |
DEFAULT_TICK_DELAY |
protected android.os.Handler |
delayedHandler |
protected static java.lang.String |
HANDLER_THREAD_NAME |
protected android.os.HandlerThread |
handlerThread |
protected boolean |
isRunning |
protected StopWatch.TickListener |
listener |
protected float |
speedMultiplier |
protected long |
startTime |
protected long |
storedTime |
protected int |
tickDelay |
protected StopWatch.TickRunnable |
tickRunnable |
protected boolean |
useHandlerThread |
| Constructor and Description |
|---|
StopWatch() |
StopWatch(boolean processOnStartingThread) |
StopWatch(android.os.Handler handler) |
| Modifier and Type | Method and Description |
|---|---|
float |
getSpeedMultiplier()
Retrieves the current multiplier used for the current time calculations.
|
int |
getTickDelay()
Retrieves the approximate duration between time updates.
|
long |
getTime()
Retrieves the current time for the stopwatch.
|
int |
getTimeInt()
Retrieves the current time for the stopwatch.
|
boolean |
isRunning()
Determines if the stopwatch is currently running
|
void |
overrideCurrentTime(long time)
Forcefully sets the current time for the stopwatch.
|
void |
reset()
Resets the current time for the stopWatch
|
void |
setSpeedMultiplier(float multiplier)
Sets the multiplier to use when calculating the passed duration.
|
void |
setTickDelay(int milliSeconds)
Sets the approximate duration between time updates.
|
void |
setTickListener(StopWatch.TickListener listener)
Sets the listener to be notified for each time update (tick)
|
void |
start()
Starts the stopwatch.
|
void |
stop()
Stops the stopwatch, capturing the ending time
|
protected static final java.lang.String HANDLER_THREAD_NAME
protected static final int DEFAULT_TICK_DELAY
protected volatile boolean isRunning
protected int tickDelay
protected android.os.Handler delayedHandler
protected android.os.HandlerThread handlerThread
protected boolean useHandlerThread
protected StopWatch.TickListener listener
protected StopWatch.TickRunnable tickRunnable
protected long startTime
protected long currentTime
protected long storedTime
protected float speedMultiplier
public StopWatch()
public StopWatch(boolean processOnStartingThread)
processOnStartingThread - True if the repeating process should be handled on the same thread that created the Repeaterpublic StopWatch(android.os.Handler handler)
handler - The Handler to use for the repeating processpublic void setTickDelay(int milliSeconds)
milliSeconds - The approximate duration between time updates [default: 33]public int getTickDelay()
public void setSpeedMultiplier(float multiplier)
setTickDelay(int) but will change
the output for the current time.multiplier - The amount to multiply the duration between each tick bypublic float getSpeedMultiplier()
public void start()
reset() first.public void stop()
public void reset()
public void overrideCurrentTime(long time)
time - The new stopwatch time in millisecondspublic boolean isRunning()
public long getTime()
public int getTimeInt()
public void setTickListener(StopWatch.TickListener listener)
listener - The listener or null