public static boolean isOnMainThread() { return Looper.myLooper() == Looper.getMainLooper(); return Thread.currentThread() == Looper.getMainLooper().getThread(); }
public static void assertMainThread() { if (!isOnMainThread()) { throw new IllegalArgumentException("You must call this method on the main thread"); } }