morristech
12/11/2018 - 9:23 PM

Check that your UI APIs are called from the UI Thread

Check that your UI APIs are called from the UI Thread

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");
			}
		}
	}
}