Skip to content

Based on android.os.CountDownTimer - Format: hh:mm:ss:ms. 基于Android原生CountDownTimer写的简单倒计时,精确到毫秒

Notifications You must be signed in to change notification settings

lgw666/SimpleCountDownTimer

Repository files navigation

SimpleCountDownTimer

  • A simple h,min,sec and ms count down timer.

  • Author:Luo Guowen

  • Email:luoguowen123@qq.com

    image

  • Setup

    Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

          allprojects {
                 		repositories {
                 			...
                 			maven { url 'https://jitpack.io' }
                 		}
                 	}
    

    Step 2. Add the dependency:

          dependencies {
          	        compile 'com.github.lgw666:SimpleCountDownTimer:1.1'
          	}
    
  • Usage

    Simple show :

    new SimpleCountDownTimer(totalTime,textView).start();

    Custom interval time:

    new SimpleCountDownTimer(totalTime,intervalTime,textView).start();

    Do something after finished:

    new SimpleCountDownTimer(totalTime, tvDisplay).setOnFinishListener(new SimpleCountDownTimer.OnFinishListener() {
              @Override
              public void onFinish() {
              do something...
              }
          }).start();
    
  • Params-unit: ms

    The number of millis in the future from the call to start() until the countdown is done and onFinish() is called.

    long totalTime;
    

    The interval time of count down.

    long intervalTime;
    

    A text view used to display count down time.

    TextView textView;
    
  • Other methods

    synchronized final CountDownTimer start(); Start the countdown.

    final void cancel(); Cancel the countdown.

About

Based on android.os.CountDownTimer - Format: hh:mm:ss:ms. 基于Android原生CountDownTimer写的简单倒计时,精确到毫秒

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages