package com.spiddekauga.utils;

import com.squareup.otto.Bus;
import com.squareup.otto.ThreadEnforcer;

/**
 * Default Otto event bus for an application.
 * @see Bus
 */
public class EventBus extends Bus {
private static EventBus mInstance = null;
private static long mMainThreadId = 1;

/**
 * Enforces singleton pattern
 */
protected EventBus(ThreadEnforcer threadEnforcer) {
	super(threadEnforcer);
}

/**
 * Set main thread id
 * @param id id of the main thread
 */
public static void setMainThreadId(long id) {
	mMainThreadId = id;
}

/**
 * Get singleton instance
 * @return get instance
 */
public static EventBus getInstance() {
	if (mInstance == null) {
		ThreadEnforcer threadEnforcer = ThreadEnforcer.MAIN;

		// Check if this is an Android application
		try {
			threadEnforcer.enforce(null);
		}
		// Regular Java application, use custom enforcer
		catch (NoClassDefFoundError e) {
			threadEnforcer = new JavaMainThreadEnforcer();
		}
		mInstance = new EventBus(threadEnforcer);
	}
	return mInstance;
}

protected static class JavaMainThreadEnforcer implements ThreadEnforcer {
	@Override
	public void enforce(Bus bus) {
		if (Thread.currentThread().getId() != mMainThreadId) {
			throw new IllegalStateException("Event bus " + bus + " accessed from non-main thread " + Thread.currentThread().getId());
		}
	}
}
}

@@ -279,16 +279,85 @@
 dId = 1;
+%0Aprivate static ThreadEnforcer mThreadEnforcer = ThreadEnforcer.MAIN;
 %0A%0A/**%0A *
@@ -598,24 +598,480 @@
 Id = id;%0A%7D%0A%0A
+/**%0A * Set default thread enforces. Must be set before the first call to %7B@link #getInstance()%7D.%0A * @param threadEnforcer the thread enforcer to use%0A */%0Apublic static void setThreadEnforcer(ThreadEnforcer threadEnforcer) %7B%0A%09if (mInstance != null) %7B%0A%09%09throw new IllegalStateException(%22Event bus already initialized%22);%0A%09%7D%0A%09if (threadEnforcer == null) %7B%0A%09%09throw new IllegalArgumentException(%22threadEnforcer is null%22);%0A%09%7D%0A%09mThreadEnforcer = threadEnforcer;%0A%7D%0A%0A
 /**%0A * Get s
@@ -1207,32 +1207,33 @@
 hreadEnforcer = 
+m
 ThreadEnforcer.M
@@ -1230,21 +1230,16 @@
 Enforcer
-.MAIN
 ;%0A%0A%09%09// 

Fix queue music and big shuttle