https://github.com/gbzarelli/chronometer-library
[ANDROID] [LIBRARY] The Chronometer Library is designed to make it easy to use a stopwatch, has features that help count turns, and a custom Widget to display the milliseconds.
https://github.com/gbzarelli/chronometer-library
android android-library chronometer-library chronometer-widget custom-widget library stopwatch
Last synced: about 1 month ago
JSON representation
[ANDROID] [LIBRARY] The Chronometer Library is designed to make it easy to use a stopwatch, has features that help count turns, and a custom Widget to display the milliseconds.
- Host: GitHub
- URL: https://github.com/gbzarelli/chronometer-library
- Owner: gbzarelli
- License: mit
- Created: 2019-05-09T17:30:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-08T13:42:12.000Z (over 6 years ago)
- Last Synced: 2025-03-15T13:25:03.254Z (about 1 year ago)
- Topics: android, android-library, chronometer-library, chronometer-widget, custom-widget, library, stopwatch
- Language: Kotlin
- Homepage:
- Size: 83 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
   
# Chronometer Library [](https://circleci.com/gh/gbzarelli/chronometer-library) [](https://jitpack.io/#gbzarelli/chronometer-library)
The Chronometer Library is designed to make it easy to use a stopwatch,
has features that help count turns, and a custom Widget to display
the milliseconds.
## Add Chronometer Library with dependency:
- Add it in your `build.gradle` (root) at the end of repositories:
```gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
- Add the dependency in your `build.gradle` project
```gradle
dependencies {
implementation 'com.github.gbzarelli:chronometer-library:2.0.0'
}
```
## How to use the ChronometerWidget
- Put in your layout xml
```xml
```
- The code
```kotlin
fun start(){
chronometer_widget.start()
}
fun reset(){
chronometer_widget.base = SystemClock.elapsedRealtime()
stop()
}
fun stop(){
chronometer_widget.stop()
}
```
## How to use the ChronometerManager class
- See `ChronometerManager.kt` and `Chronometer.kt`
```kotlin
val manager = ChronometerManager { SystemClock.elapsedRealtime() }
manager.start()
Thread.sleep(1000) // +1s
manager.lap()
manager.pause()
Thread.sleep(1000) // 1s paused
manager.start()
Thread.sleep(1000) // +1s
manager.stop()
print(ChronometerUtils.getFormattedTime(manager.getChronometerTime()))
val obChronometer = manager.chronometer
println(obChronometer)
manager.reset()
```
## Project Sample
- Play Store: [Swimming Stopwatch (Lap counter)](https://play.google.com/store/apps/details?id=br.com.helpdev.lapscounter.swimming&hl=en)
- Github: [LapsCounter](https://github.com/gbzarelli/LapsCounter)
# Licence
[MIT](https://choosealicense.com/licenses/mit/)