Demo entry 6354054

sss

   

Submitted by anonymous on Apr 04, 2017 at 18:06
Language: Java. Code size: 604 Bytes.

public final class TedBusProvider extends Bus{

	private static TedBusProvider instance;

	public static TedBusProvider getInstance() {

		if(instance==null)
			instance = new TedBusProvider();

		return instance;
	}


	private final Handler mHandler = new Handler(Looper.getMainLooper());

	@Override
	public void post(final Object event) {


		if (Looper.myLooper() == Looper.getMainLooper()) {
			super.post(event);
		} else {
			mHandler.post(new Runnable() {
				@Override
				public void run() {
					TedBusProvider.getInstance().post(event);
				}
			});
		}


	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).