Skip to content

Instantly share code, notes, and snippets.

@macsystems
Created March 28, 2013 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macsystems/5262760 to your computer and use it in GitHub Desktop.
Save macsystems/5262760 to your computer and use it in GitHub Desktop.
Some Proxy class to get Logging for register/unregister of Objects in greenrobots EventBus
import android.util.Log;
import com.google.common.eventbus.EventBus;
/**
* An Proxy which allows better log control
*
* @author Jens Hohl
*
*/
public final class EventBusProxy
{
private final static String LOG_TAG = EventBusProxy.class.getSimpleName();
private final EventBus bus = new EventBus("NameOfBus");
private static EventBusProxy proxy = new EventBusProxy();
private EventBusProxy()
{
}
/**
* get instance of the EventBus
*
* @return
*/
public static EventBusProxy get()
{
return proxy;
}
public void post(final Object event)
{
Log.d(LOG_TAG, "Posting Event :" + event.getClass().getSimpleName());
bus.post(event);
}
public void register(final Object object)
{
Log.d(LOG_TAG, "Register :" + object.getClass().getSimpleName());
bus.register(object);
}
public void unregister(final Object object)
{
Log.d(LOG_TAG, "Register :" + object.getClass().getSimpleName());
bus.unregister(object);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment