UNPKG

@nativescript/core

Version:

A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.

28 lines 838 B
import { android as androidHelper } from './native-helper'; export function dispatchToMainThread(func) { const runOnMainThread = global.__runOnMainThread; if (runOnMainThread) { runOnMainThread(() => { func(); }); } else { new android.os.Handler(android.os.Looper.getMainLooper()).post(new java.lang.Runnable({ run: func, })); } } export function isMainThread() { return android.os.Looper.myLooper() === android.os.Looper.getMainLooper(); } export function dispatchToUIThread(func) { const activity = androidHelper.getCurrentActivity(); if (activity && func) { activity.runOnUiThread(new java.lang.Runnable({ run() { func(); }, })); } } //# sourceMappingURL=mainthread-helper.android.js.map