@Test public void onUnsubscribeRunsSyncOnMainThread() { ShadowLooper.pauseMainLooper(); final AtomicBoolean called = new AtomicBoolean(); new AbstractDisposeOnMainThread() { @Override protected void onDispose() { called.set(true); } }.dispose(); assertTrue(called.get()); }
@Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (Looper.myLooper() == Looper.getMainLooper()) { onDispose(); } else { AndroidInteropSchedulers.mainThread().scheduleDirect(new Runnable() { @Override public void run() { onDispose(); } }); } } }
AbstractDisposeOnMainThread implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (Looper.myLooper() == Looper.getMainLooper()) { onDispose(); } else { AndroidInteropSchedulers.mainThread().scheduleDirect(new Runnable() { @Override public void run() { onDispose(); } }); } } } }
AbstractDisposeOnMainThread implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (Looper.myLooper() == Looper.getMainLooper()) { onDispose(); } else { AndroidInteropSchedulers.mainThread().scheduleDirect(new Runnable() { @Override public void run() { onDispose(); } }); } } }  }
AbstractDisposeOnMainThread implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (Looper.myLooper() == Looper.getMainLooper()) { onDispose(); } else { AndroidInteropSchedulers.mainThread().scheduleDirect(new Runnable() { @Override public void run() { onDispose(); } }); } } }  static void verifyMainThread(); @Override final boolean isDisposed(); @Override final void dispose(); }
AbstractDisposeOnMainThread implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (Looper.myLooper() == Looper.getMainLooper()) { onDispose(); } else { AndroidInteropSchedulers.mainThread().scheduleDirect(new Runnable() { @Override public void run() { onDispose(); } }); } } }  static void verifyMainThread(); @Override final boolean isDisposed(); @Override final void dispose();  }