Skip to content

Android-Hourglass is a Countdown timer that provides the feature of pausing the timer.

License

Notifications You must be signed in to change notification settings

groverankush/Hourglass

Repository files navigation

Hourglass

Open Source Love License: MIT

Hourglass is a Countdown timer that provides the feature to pause and resume the timer. The module is loaded with convenience methods to get a way through timers.

Getting Started

These are the all the instructions you need to use Hourglass in your apps.

Compile

Just a simple implementation will get you up and running with Hourglass.

implementation 'com.ankushgrover:Hourglass:2.0.0'

OR

compile 'com.ankushgrover:Hourglass:2.0.0'

Adding this line will enable you to use every feature Hourglass has.

Usage

Just initialize an object of Hourglass. The class is loaded with a lot of convinience methods to handle various actions. Some of them are listed below:

  • Three constructors for initializing
        public Hourglass()       //default interval is 1 second
        public Hourglass(time)   //default interval is 1 second 
        public Hourglass(time, interval)  
  • Convineince methods to manage timer
        public void startTimer()
        public void stopTimer()
        public void pauseTimer()
        public void resumeTimer()
  • Abstract methods for updating UI
        public void onTimerTick(long timeRemaining)    // Called after every interval.
        public void onTimerFinish()                    // Called when time specified finishes 
  • Setters for setting time and interval
        public void setTime(long time)
        public void setInterval(long interval)

Examples

Here is an example:

        Hourglass hourglass = new Hourglass(50000, 1000) {
            @Override
            public void onTimerTick(long timeRemaining) {
                // Update UI
                Toast.show(MainActivity.this, String.valueOf(timeRemaining), Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onTimerFinish() {
                // Timer finished
                Toast.show(MainActivity.this, "Timer finished", Toast.LENGTH_SHORT).show();


            }
        };
        
        hourglass.startTimer();

Built With

  • Android SDK
  • Maven - Dependency Management

Author

Ankush Grover

License

This project is licensed under MIT License, - see the LICENSE.md file for details

About

Android-Hourglass is a Countdown timer that provides the feature of pausing the timer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages