@Test public void onDisposeFailsWhenMainThreadCheckNotSet() { try { new MainThreadDisposable() { @Override protected void onDispose() {} }.dispose(); throw new AssertionError("Expected to fail before this due to Looper not being stubbed!"); } catch (RuntimeException e) { } }
@Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (AutoDisposeAndroidUtil.isMainThread()) { onDispose(); } else { AndroidSchedulers.mainThread().scheduleDirect(this::onDispose); } } }
MainThreadDisposable implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (AutoDisposeAndroidUtil.isMainThread()) { onDispose(); } else { AndroidSchedulers.mainThread().scheduleDirect(this::onDispose); } } } }
MainThreadDisposable implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (AutoDisposeAndroidUtil.isMainThread()) { onDispose(); } else { AndroidSchedulers.mainThread().scheduleDirect(this::onDispose); } } }  }
MainThreadDisposable implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (AutoDisposeAndroidUtil.isMainThread()) { onDispose(); } else { AndroidSchedulers.mainThread().scheduleDirect(this::onDispose); } } }  @Override final boolean isDisposed(); @Override final void dispose(); }
MainThreadDisposable implements Disposable { @Override public final void dispose() { if (unsubscribed.compareAndSet(false, true)) { if (AutoDisposeAndroidUtil.isMainThread()) { onDispose(); } else { AndroidSchedulers.mainThread().scheduleDirect(this::onDispose); } } }  @Override final boolean isDisposed(); @Override final void dispose();  }