Skip to content

Instantly share code, notes, and snippets.

@Orange168
Created September 3, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Orange168/a87f116ce93bc7f2624fa001d2d93f77 to your computer and use it in GitHub Desktop.
Save Orange168/a87f116ce93bc7f2624fa001d2d93f77 to your computer and use it in GitHub Desktop.
[Observer 返回空] #RxJava
public static boolean checkMainThread(Observer<?> observer) {
if (Looper.myLooper() != Looper.getMainLooper()) {
observer.onSubscribe(Disposables.empty());
observer.onError(new IllegalStateException(
"Expected to be called on the main thread but was " + Thread.currentThread().getName()));
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment