Skip to content

[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.

License

Notifications You must be signed in to change notification settings

gbzarelli/chronometer-library

Repository files navigation

Issues Forks Stars Release Version

Chronometer Library CircleCI

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:
	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}
  • Add the dependency in your build.gradle project
	dependencies {
	        implementation 'com.github.gbzarelli:chronometer-library:2.0.0'
	}

How to use the ChronometerWidget

  • Put in your layout xml
<br.com.helpdev.chronometerlib.widget.ChronometerWidget
        android:id="@+id/chronometer_widget"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"/>
  • The code
    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
        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

Licence

MIT

About

[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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages