Created
September 7, 2015 16:01
-
-
Save juanmendez/4c891b2e028e5a5bcdb5 to your computer and use it in GitHub Desktop.
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
package YOUR_PACKAGE; | |
import android.os.Handler; | |
import android.os.Looper; | |
import com.squareup.otto.Bus; | |
public class BusUtil | |
{ | |
private static final Handler mainThread = new Handler(Looper.getMainLooper()); | |
/** | |
* making sure your bus update goes into the main thread | |
* @see <a href="http://square.github.io/otto/" target="_blank">Otto</a> | |
**/ | |
public static void postOnMain( final Bus bus, final Object event) { | |
mainThread.post(new Runnable() { | |
@Override | |
public void run() { | |
bus.post(event); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment