Created
September 3, 2018 12:34
-
-
Save Orange168/a87f116ce93bc7f2624fa001d2d93f77 to your computer and use it in GitHub Desktop.
[Observer 返回空] #RxJava
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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