Android 倒计时CountDownTimer 的使用

/**
 * 倒计时类
 *
 * @author tab
 */
public class TimerDownTab extends CountDownTimer {
    private TimerDownListener listener;

    public interface TimerDownListener {
        void onTick(long millis);

        void onFinish();
    }

    public void setOnTimerDownListener(TimerDownListener listener) {
        this.listener = listener;
    }

    /**
     * @param millisInFuture    总时间
     * @param countDownInterval 间隔跳动时间
     */
    public TimerDownTab(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onTick(long millisUntilFinished) {
        if (listener != null) {
            listener.onTick(millisUntilFinished);
        }
    }

    @Override
    public void onFinish() {
        if (listener != null) {
            listener.onFinish();
        }
    }

}

  

posted @ 2022-05-27 21:51  bg_不够  阅读(101)  评论(0编辑  收藏  举报