Java Code Examples for com.topjohnwu.superuser.ShellUtils#onMainThread()
The following examples show how to use
com.topjohnwu.superuser.ShellUtils#onMainThread() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UiThreadHandler.java From libsu with Apache License 2.0 | 5 votes |
public static void run(Runnable r) { if (ShellUtils.onMainThread()) { r.run(); } else { handler.post(r); } }
Example 2
Source File: UiThreadHandler.java From libsu with Apache License 2.0 | 5 votes |
public static void runWithLock(Object lock, Runnable r) { if (ShellUtils.onMainThread()) { synchronized (lock) { r.run(); } } else { handler.post(() -> { synchronized (lock) { r.run(); } }); } }
Example 3
Source File: UiThreadHandler.java From libsu with Apache License 2.0 | 5 votes |
public static void runAndWait(Runnable r) { if (ShellUtils.onMainThread()) { r.run(); } else { WaitRunnable wr = new WaitRunnable(r); handler.post(wr); wr.waitUntilDone(); } }