package com.wallstreetcn.helper.utils;
import android.widget.TextView;
public class MsgCountDownTimer extends android.os.CountDownTimer {
private TextView view;
public MsgCountDownTimer(TextView view, long millisInFuture) {
super(millisInFuture, 1000);
this.view = view;
}
@Override
public void onTick(long millisUntilFinished) {
try {
String text = "重新获取" + millisUntilFinished / 1000;
view.setText(text);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onFinish() {
try {
view.setText("获取验证码");
view.setEnabled(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
CountDownTimer countDownTimer;
@Override
public void onGetMsgSucc() {
sendMsgBtn.setEnabled(false);
countDownTimer = new MsgCountDownTimer(sendMsgBtn, 60 * 1000);
countDownTimer.start();
}
@Override
public void onMsgSendFail() {
sendMsgBtn.setEnabled(true);
}
@Override
public void onRegisterFail() {
sendMsgBtn.setEnabled(true);
}
super.onDestroy();
if (countDownTimer != null) {
countDownTimer.cancel();
}