summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-01-31 16:41:42 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-01-31 16:41:42 +0000
commitfd6a44d0b5b6bcfc606abf23520b316c4bf36fc4 (patch)
tree9aea6d2f9fe52e692323f09f717688799e990a28 /core/java/android/os
parent5ec133b9a0949cda92c5c287169aba86ad615065 (diff)
parentff62e966b60bb20dc7c3384485816b1e7bf06057 (diff)
downloadframeworks_base-fd6a44d0b5b6bcfc606abf23520b316c4bf36fc4.zip
frameworks_base-fd6a44d0b5b6bcfc606abf23520b316c4bf36fc4.tar.gz
frameworks_base-fd6a44d0b5b6bcfc606abf23520b316c4bf36fc4.tar.bz2
am ff62e966: am 149510e0: am b9f960e0: Merge "Fixed cancel() not working correctly"
* commit 'ff62e966b60bb20dc7c3384485816b1e7bf06057': Fixed cancel() not working correctly
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/CountDownTimer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java
index c5b1146..58acbcf 100644
--- a/core/java/android/os/CountDownTimer.java
+++ b/core/java/android/os/CountDownTimer.java
@@ -54,6 +54,11 @@ public abstract class CountDownTimer {
private final long mCountdownInterval;
private long mStopTimeInFuture;
+
+ /**
+ * boolean representing if the timer was cancelled
+ */
+ private boolean mCancelled = false;
/**
* @param millisInFuture The number of millis in the future from the call
@@ -70,7 +75,8 @@ public abstract class CountDownTimer {
/**
* Cancel the countdown.
*/
- public final void cancel() {
+ public synchronized final void cancel() {
+ mCancelled = true;
mHandler.removeMessages(MSG);
}
@@ -78,6 +84,7 @@ public abstract class CountDownTimer {
* Start the countdown.
*/
public synchronized final CountDownTimer start() {
+ mCancelled = false;
if (mMillisInFuture <= 0) {
onFinish();
return this;
@@ -110,6 +117,10 @@ public abstract class CountDownTimer {
public void handleMessage(Message msg) {
synchronized (CountDownTimer.this) {
+ if (mCancelled) {
+ return;
+ }
+
final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime();
if (millisLeft <= 0) {