Created
November 29, 2012 09:59
-
-
Save pyricau/4167919 to your computer and use it in GitHub Desktop.
Check that your UI APIs are called from the UI Thread
This file contains hidden or 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 class ThreadPreconditions { | |
public static void checkOnMainThread() { | |
if (BuildConfig.DEBUG) { | |
if (Thread.currentThread() != Looper.getMainLooper().getThread()) { | |
throw new IllegalStateException("This method should be called from the Main Thread"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment