其他分享
首页 > 其他分享> > Android 倒计时CountDownTimer 的使用

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();
        }
    }

}

  

标签:listener,onTick,void,long,倒计时,countDownInterval,Android,public,CountDownTimer
来源: https://www.cnblogs.com/bg-tab/p/16319240.html