package com.xyxsbj.mylibrary.tool;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * 包名: com.fkxt.app.widget
 * 类名: CountDownTimerUtil
 * 作用描述:
 * 创建人: mQ
 * 创建时间: 2020/3/13 10:45
 * 更新人:
 * 更新时间: 2020/3/13 10:45
 * 更新说明:
 * 版本号: 1.0
 */
public class CountDownTimerUtil extends CountDownTimer {
    private TextView mTextView;

    /**
     * @param millisInFuture    The number of millis in the future from the call
     *                          to {@link #start()} until the countdown is done and {@link #onFinish()}
     *                          is called.
     * @param countDownInterval The interval along the way to receive
     *                          {@link #onTick(long)} callbacks.
     */
    public CountDownTimerUtil(TextView textView, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        mTextView = textView;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mTextView.setEnabled(false);
        mTextView.setText(millisUntilFinished / 1000 + "秒后可重新发送");  //设置倒计时时间
    }

    @Override
    public void onFinish() {
        mTextView.setEnabled(true);
        mTextView.setText("获取短信验证码");

    }
}
