UNPKG

838 BJavaScriptView Raw
1import { android as androidHelper } from './native-helper';
2export function dispatchToMainThread(func) {
3 const runOnMainThread = global.__runOnMainThread;
4 if (runOnMainThread) {
5 runOnMainThread(() => {
6 func();
7 });
8 }
9 else {
10 new android.os.Handler(android.os.Looper.getMainLooper()).post(new java.lang.Runnable({
11 run: func,
12 }));
13 }
14}
15export function isMainThread() {
16 return android.os.Looper.myLooper() === android.os.Looper.getMainLooper();
17}
18export function dispatchToUIThread(func) {
19 const activity = androidHelper.getCurrentActivity();
20 if (activity && func) {
21 activity.runOnUiThread(new java.lang.Runnable({
22 run() {
23 func();
24 },
25 }));
26 }
27}
28//# sourceMappingURL=mainthread-helper.android.js.map
\No newline at end of file