Java Code Examples for com.facebook.react.bridge.UiThreadUtil#isOnUiThread()
The following examples show how to use
com.facebook.react.bridge.UiThreadUtil#isOnUiThread() .
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: MessageQueueThreadImpl.java From react-native-GPay with MIT License | 6 votes |
/** * @return a MessageQueueThreadImpl corresponding to Android's main UI thread. */ private static MessageQueueThreadImpl createForMainThread( String name, QueueThreadExceptionHandler exceptionHandler) { Looper mainLooper = Looper.getMainLooper(); final MessageQueueThreadImpl mqt = new MessageQueueThreadImpl(name, mainLooper, exceptionHandler); if (UiThreadUtil.isOnUiThread()) { Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY); } else { UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY); } }); } return mqt; }
Example 2
Source File: DevSupportManagerImpl.java From react-native-GPay with MIT License | 5 votes |
@Override public void reloadSettings() { if (UiThreadUtil.isOnUiThread()) { reload(); } else { UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { reload(); } }); } }
Example 3
Source File: NativeAnimatedNodesManager.java From react-native-GPay with MIT License | 5 votes |
@Override public void onEventDispatch(final Event event) { // Events can be dispatched from any thread so we have to make sure handleEvent is run from the // UI thread. if (UiThreadUtil.isOnUiThread()) { handleEvent(event); } else { UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { handleEvent(event); } }); } }