From a89489512f4740028ef52603d533b86256deb3d6 Mon Sep 17 00:00:00 2001 From: atanasovg Date: Thu, 24 Sep 2015 17:08:08 +0300 Subject: [PATCH 1/2] Fix #817 --- timer/timer.android.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/timer/timer.android.ts b/timer/timer.android.ts index b14e3e33e..8b2dc7d3d 100644 --- a/timer/timer.android.ts +++ b/timer/timer.android.ts @@ -50,7 +50,9 @@ export function setInterval(callback: Function, milliseconds = 0): number { var runnable = new java.lang.Runnable({ run: () => { callback(); - handler.postDelayed(runnable, long(milliseconds)); + if (timeoutCallbacks[id]) { + handler.postDelayed(runnable, long(milliseconds)); + } } }); From 3e30623103fe5741bb28c3fc067273c528b3ec82 Mon Sep 17 00:00:00 2001 From: atanasovg Date: Wed, 30 Sep 2015 14:37:40 +0300 Subject: [PATCH 2/2] Fix the setInterval test. --- apps/tests/timer-tests.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/tests/timer-tests.ts b/apps/tests/timer-tests.ts index 26e418a35..f212e3f6f 100644 --- a/apps/tests/timer-tests.ts +++ b/apps/tests/timer-tests.ts @@ -136,8 +136,7 @@ export var test_setInterval_callbackCalledDuringPeriod = function () { export var test_setInterval_callbackShouldBeCleared = function () { var counter = 0; - var expected = 1; - var isReady = function () { return counter === expected; } + var isReady = function () { return false; } // // ### Cancel the interval previously started using the setInterval method. @@ -152,5 +151,5 @@ export var test_setInterval_callbackShouldBeCleared = function () { // TKUnit.waitUntilReady(isReady, 0.5); - TKUnit.assert(isReady(), "Callback should be raised only once!"); -}; + TKUnit.assert(counter === 1, "Callback should be raised only once!"); +}; \ No newline at end of file