Skip to content

xesam/AndroidTimer

Repository files navigation

android-timer

基于Handler的Android定时器与倒计时器

源码地址:Github AndroidTimer

特性

支持操作 :

  1. start
  2. pause
  3. resume
  4. cancel

使用

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    ...
    compile 'com.github.xesam:AndroidTimer:v0.1'
}

TODO

  • add ticker sequence

使用

CountTimer

    new CountTimer(100) {

        @Override
        public void onTick(long millisFly) { // millisFly is the Elapsed time at *Running State*
            vCountSwitcher.setText((millisFly) + "");
            Log.d("onTick", millisFly + "");
        }
    };

CountDownTimer

    new CountDownTimer(10_000, 100) {

        @Override
        public void onTick(long millisUntilFinished) { // millisUntilFinished is the left time at *Running State*
            Log.d("onTick", millisFly + "");
        }

        @Override
        public void onCancel(long millisUntilFinished) {
        }

        @Override
        public void onPause(long millisUntilFinished) {
        }

        @Override
        public void onResume(long millisUntilFinished) {
        }

        @Override
        public void onFinish() {
        }
    };

截图

timer

参考自 Android SDK 中的 CountDownTimer

About

基于Handler的Android定时器与倒计时器

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages