@Override public boolean isMainThread() { return looper == Looper.myLooper(); }
/** * Returns {@code true} if called on the main thread, {@code false} otherwise. */ public static boolean isOnMainThread() { return Looper.myLooper() == Looper.getMainLooper(); }
@Override public void runOnUiThread (Runnable runnable) { if (Looper.myLooper() != Looper.getMainLooper()) { // The current thread is not the UI thread. // Let's post the runnable to the event queue of the UI thread. new Handler(Looper.getMainLooper()).post(runnable); } else { // The current thread is the UI thread already. // Let's execute the runnable immediately. runnable.run(); } }
@Override public void runOnUiThread (Runnable runnable) { if (Looper.myLooper() != Looper.getMainLooper()) { // The current thread is not the UI thread. // Let's post the runnable to the event queue of the UI thread. new Handler(Looper.getMainLooper()).post(runnable); } else { // The current thread is the UI thread already. // Let's execute the runnable immediately. runnable.run(); } }
@Override public void runOnUiThread (Runnable runnable) { if (Looper.myLooper() != Looper.getMainLooper()) { // The current thread is not the UI thread. // Let's post the runnable to the event queue of the UI thread. new Handler(Looper.getMainLooper()).post(runnable); } else { // The current thread is the UI thread already. // Let's execute the runnable immediately. runnable.run(); } }
@Override public void runOnUiThread (Runnable runnable) { if (Looper.myLooper() != Looper.getMainLooper()) { // The current thread is not the UI thread. // Let's post the runnable to the event queue of the UI thread. new Handler(Looper.getMainLooper()).post(runnable); } else { // The current thread is the UI thread already. // Let's execute the runnable immediately. runnable.run(); } }
/** * Throws {@link IllegalStateException} if the calling thread is not the application's main * thread. * * @throws IllegalStateException If the calling thread is not the application's main thread. */ public static void checkMainThread() { if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && Looper.myLooper() != Looper.getMainLooper()) { throw new IllegalStateException("Not in applications main thread"); } }
private static Handler defineHandler(DisplayImageOptions options) { Handler handler = options.getHandler(); if (options.isSyncLoading()) { handler = null; } else if (handler == null && Looper.myLooper() == Looper.getMainLooper()) { handler = new Handler(); } return handler; }
@Override public boolean setImageBitmap(Bitmap bitmap) { if (Looper.myLooper() == Looper.getMainLooper()) { View view = viewRef.get(); if (view != null) { setImageBitmapInto(bitmap, view); return true; } } else { L.w(WARN_CANT_SET_BITMAP); } return false; }
private void verifyApplicationThread() { if (Looper.myLooper() != getApplicationLooper()) { Log.w( TAG, "Player is accessed on the wrong thread. See " + "https://google.github.io/ExoPlayer/faqs.html#" + "what-do-player-is-accessed-on-the-wrong-thread-warnings-mean", hasNotifiedFullWrongThreadWarning ? null : new IllegalStateException()); hasNotifiedFullWrongThreadWarning = true; } }
@Override public void onLoadCanceled( int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) { Assertions.checkState(Looper.myLooper() == playbackThread.getLooper()); }
@Override public void onDownstreamFormatChanged( int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) { Assertions.checkState(Looper.myLooper() == playbackThread.getLooper()); } }
@Subscribe(threadMode = ThreadMode.ASYNC) public void onEventAsync(Object event) { assertNotSame(Looper.getMainLooper(), Looper.myLooper()); } }
@Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(String event) { assertSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe(threadMode = ThreadMode.BACKGROUND) public void onEventBackgroundThread(Integer event) { assertNotSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe public void onEvent(Object event) { assertNotSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe public void onEvent(String event) { trackEvent(event); assertNotSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(String event) { trackEvent(event); assertSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe(threadMode = ThreadMode.BACKGROUND) public void onEventBackgroundThread(String event) { trackEvent(event); assertNotSame(Looper.getMainLooper(), Looper.myLooper()); }
@Subscribe(threadMode = ThreadMode.ASYNC) public void onEventAsync(String event) { trackEvent(event); assertNotSame(Looper.getMainLooper(), Looper.myLooper()); }