mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
definitions fixed
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Android specific timer functions implementation.
|
||||
*/
|
||||
* Android specific timer functions implementation.
|
||||
*/
|
||||
var timeoutHandler;
|
||||
var timeoutCallbacks = {};
|
||||
|
||||
@@ -18,7 +18,10 @@ export function setTimeout(callback: Function, milliseconds = 0): number {
|
||||
var runnable = new java.lang.Runnable({
|
||||
run: () => {
|
||||
callback();
|
||||
timeoutCallbacks[id] = null;
|
||||
|
||||
if (timeoutCallbacks && timeoutCallbacks[id]) {
|
||||
timeoutCallbacks[id] = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -40,11 +43,12 @@ export function clearTimeout(id: number): void {
|
||||
|
||||
export function setInterval(callback: Function, milliseconds = 0): number {
|
||||
var id = createHadlerAndGetId();
|
||||
var handler = timeoutHandler;
|
||||
|
||||
var runnable = new java.lang.Runnable({
|
||||
run: () => {
|
||||
callback();
|
||||
timeoutHandler.postDelayed(runnable, long(milliseconds));
|
||||
handler.postDelayed(runnable, long(milliseconds));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user