package com.danding.yang800.View;

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

/**
 * Created by Administrator on 2017/8/17.
 */
public class AuthCodeCountDown extends CountDownTimer {
    private TextView text;

    public AuthCodeCountDown(long millisInFuture, TextView text) {
        super(millisInFuture, 1000);
        this.text = text;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        long second = 0L;
        if (millisUntilFinished > 0)
            second = millisUntilFinished / 1000 - 1;
        if (text != null)
            text.setText(second + "s");
    }

    @Override
    public void onFinish() {
        if (text != null) {
            text.setText("重发验证码");
            text.setEnabled(true);
        }
    }
}
