##Description Android doesn't have a built in stopwatch, it only has the CountDownTimer. So I built a stopwatch class that can be easily used.
##Usage
The interface is easy to use:
-
To start the stopwatch you call start() method.
-
To start the stopwatch with a given offset pass in the offset as a parameter to start. (Ex: If you want to start the time from 00:00:10 not 00:00:00)
-
To get the current time there are multiple convienece methods to get each component. An easier approach is to call the toString() that will return the time in the form of HH:MM:SS
Stopwatch stopWatch = new Stopwatch();
stopwatch.start();
long minutes = stopwatch.getElapsedTimeMin();
Log.d("Time", stopwatch.toString());
- You can add a listener to listen for tick events every second by calling the Stopwatch(StopwatchListener listener) or stopwatch.setListener(StopwatchListener listener)
##TODO
- Make the listining period dynamic and provided by the client.
- Add more convience methods to print the time in different formats
- Add different views for the class to display the time on.
- Add a gradle plugin.
##License
The logic was inspired by this answer on StackOverflow.