/** * 倒计时类 * * @author tab */ public class TimerDownTab extends CountDownTimer { private TimerDownListener listener; public interface TimerDownListener { void onTick(long millis); void onFinish(); } public void setOnTimerDownListener(TimerDownListener listener) { this.listener = listener; } /** * @param millisInFuture 总时间 * @param countDownInterval 间隔跳动时间 */ public TimerDownTab(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onTick(long millisUntilFinished) { if (listener != null) { listener.onTick(millisUntilFinished); } } @Override public void onFinish() { if (listener != null) { listener.onFinish(); } } }
原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/tech/272595.html