Back to project page android-open-street-map.
The source code is released under:
Apache License
If you think the Android project android-open-street-map listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android.lib.map.osm.utils; /*from w ww. j a v a 2s . com*/ import android.os.Handler; public abstract class CountDownTimer { private long millisInFuture; private long countDownInterval; private boolean cancelled; public abstract void onFinish(); public abstract void onTick(); public CountDownTimer(long aMillisInFuture, long aCountDownInterval) { this.millisInFuture = aMillisInFuture; this.countDownInterval = aCountDownInterval; } public void start() { cancelled = false; final Handler handler = new Handler(); final Runnable counter = new Runnable() { @Override public void run() { if (millisInFuture <= 0 || cancelled) { onFinish(); } else { onTick(); millisInFuture -= countDownInterval; handler.postDelayed(this, countDownInterval); } } }; handler.postDelayed(counter, countDownInterval); } public void cancel() { cancelled = true; } }