PHP直播源码,验证码倒计时相关的代码
import android.os.CountDownTimer;
import android.widget.TextView;
public class SmsCodeHelper {
private final TextView textView;
private final long seconds;
public SmsCodeHelper(TextView text, long seconds) {
this.seconds = seconds;
this.textView = text;
}
public interface SmsTimerCall {
void call(boolean finished);
}
public void smsCodeGet(SmsTimerCall call) {
CountDownTimer timer = new CountDownTimer(this.seconds, 1000) {
@Override
public void onTick(long l) {
textView.setClickable(false);
textView.setEnabled(false);
textView.setText(String.format("%s秒后重试", l / 1000 + 1));
call.call(false);
}
@Override
public void onFinish() {
textView.setText("重新获取");
textView.setClickable(true);
textView.setEnabled(true);
call.call(true);
}
};
timer.start();
}
}
以上就是PHP直播源码,验证码倒计时相关的代码, 更多内容欢迎关注之后的文章