Giter Site home page Giter Site logo

orbitalsonic / soniccountdowntimer Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 589 KB

SonicCountDownTimer for Android sets countdown based on user-defined interval, allowing pausing and resuming functionality, catering to diverse needs.

License: Other

Kotlin 100.00%
countdown-timer countdowntimer timer

soniccountdowntimer's Introduction

CountDownTimer-With-Pause-Resume-Android-Kotlin

CountDownTimer in Android is used to set a countdown based on interval set by you and it will stop when the time has come in future. You can use this Count Down Timer for creating any countdown for an event. But in some cases we need Pause or Resume CountDownTimer but it doesn't have Pause and Resume methods. SonicCountDownTimer library will fulfill this need.

Add Gradle Files

Add maven repository in project level build.gradle or in latest project setting.gradle file

repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

Add following dependency in app gradle file
  implementation 'com.github.orbitalsonic:SonicCountDownTimer:1.0.5'
 

Java or Kotlin

Three constructors for initializing
    SonicCountDownTimer()       //default time interval is 1 second
    SonicCountDownTimer(timeInMillis: Long)   //default time interval is 1 second 
    SonicCountDownTimer(timeInMillis: Long, intervalInMillis: Long)
Methods to manage countdown timer
    fun startCountDownTimer()
    fun pauseCountDownTimer()
    fun resumeCountDownTimer()
    fun stopCountDownTimer()
    fun cancelCountDownTimer()
Abstract methods for updating UI
    fun onTimerTick(timeRemaining: Long)    // Called after every time interval.
    fun onTimerFinish()                   // Called when time specified finishes 
Setters & Getters
    fun setCountDownTime(timeInMillis: Long)
    fun setTimeInterval(intervalInMillis: Long)
    fun getRemainingTime(): Long

Example

       val  sonicCountDownTimer =
        object : SonicCountDownTimer(30000, 1000) {

            override fun onTimerTick(timeRemaining: Long) {
                // Update UI

            }

            override fun onTimerFinish() {
                // CountDownTimer finished

            }

        }

    sonicCountDownTimer.startCountDownTimer()

Screenshots

alt text alt text

soniccountdowntimer's People

Contributors

myaqoob7 avatar orbitalsonic avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

soniccountdowntimer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.