内部提供方法初始化和获取验证码内容
image_code.setImageBitmap(Code.getInstance().createBitmap()); //初始化验证码
Code.getInstance().getCode(); //获取验证码
计时器
public abstract class CountDownTimer {
/**
- Millis since epoch when alarm should stop.
执行的总时间
*/
private final long mMillisInFuture;
/**
- The interval in millis that the user receives callbacks
时间间隔
*/
private final long mCountdownInterval;
// 停止时间
private long mStopTimeInFuture;
/**
-
@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 CountDownTimer(long millisInFuture, long countDownInterval) {
mMillisInFuture = millisInFuture;
mCountdownInterval = countDownInterval;
}
/**
- Cancel the countdown.
取消到timer
*/
public final void cancel() {
mHandler.removeMessages(MSG);
}
/**
- Start the countdown.
开始
*/
public synchronized final CountDownTimer start() {
if (mMillisInFuture <= 0) {
onFinish();
return this;
}
// 停止时间 = 系统启动时间 + 总计时间
mStopTimeInFuture = SystemClock.elapsedRealtime() + mMillisInFuture;
mHandler.sendMessage(mHandler.obtainMessage(MSG));
return this;
}
/**
-
Callback fired on regular interval.
-
@param millisUntilFinished The amount of time until finished.
*/
public abstract void onTick(long millisUntilFinished);
/**
- Callback fired when the time is up.
*/