List of usage examples for android.os Looper myLooper
public static @Nullable Looper myLooper()
From source file:com.cnblogs.app.http.async.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*from w ww .j a v a2 s . co m*/ @SuppressLint("HandlerLeak") public AsyncHttpResponseHandler() { // Set up a handler to post events back to the correct thread if possible if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.ytrain.mutrain.utils.asynchttp.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//* w w w.ja va2s . c o m*/ public AsyncHttpResponseHandler() { // Set up a handler to post events back to the correct thread if // possible?handle?? if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.cloudsynch.quickshare.http.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*from w w w. jav a2 s . co m*/ public AsyncHttpResponseHandler(ResultParser<T> parser) { // Set up a handler to post events back to the correct thread if // possible mParser = parser; if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.chuannuo.tangguo.net.TGHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *///from w ww. j a v a 2 s . c o m public TGHttpResponseHandler() { // Set up a handler to post events back to the correct thread if possible if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { TGHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.onecase.chatroom.service.DataLayerService.java
private void startSendThread() { Thread t = new Thread() { @Override/*from w w w. j a va 2s . co m*/ public void run() { Looper.prepare(); sendDataHandler = new OCHandler(Looper.myLooper()); Looper.loop(); } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); while (sendDataHandler == null) ; }
From source file:com.baidu.asynchttpclient.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*w ww. java2s . c o m*/ public AsyncHttpResponseHandler() { // Set up a handler to post events back to the correct thread if possible if (Looper.myLooper() != null) { handler = new Handler() { public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:nl.sebastiaanschool.contact.app.gui.GrabBag.java
static void assertOnMainThread() { if (Looper.myLooper() != Looper.getMainLooper()) { throw new IllegalStateException("not on main thread"); }/*from w w w . ja v a 2s . co m*/ }
From source file:ua.at.tsvetkov.data_processor.ProcessingCentre.java
/** * @param request/*from w ww. j a v a 2 s .com*/ * @param clazz */ public ProcessingCentre(Request request, Class<T> clazz) { if (request == null || clazz == null) { throw new InvalidParameterException(INVALID_PARAMETER); } this.request = request; this.clazz = clazz; this.callback = null; if (Looper.myLooper() != null) handler = new Handler(); else handler = null; thread = Thread.currentThread(); }
From source file:com.corebase.android.framework.http.client.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*from w w w . ja v a 2 s . c om*/ public AsyncHttpResponseHandler() { // Set up a handler to post events back to the correct thread if // possible if (Looper.myLooper() != null) { handler = new Handler() { public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:android.support.test.espresso.base.ThreadPoolExecutorExtractor.java
private <T> FutureTask<T> runOnMainThread(final FutureTask<T> futureToRun) { if (Looper.myLooper() != Looper.getMainLooper()) { final CountDownLatch latch = new CountDownLatch(1); mainHandler.post(new Runnable() { @Override// w w w.j a va 2 s . co m public void run() { try { futureToRun.run(); } finally { latch.countDown(); } } }); try { latch.await(); } catch (InterruptedException ie) { if (!futureToRun.isDone()) { throw new RuntimeException("Interrupted while waiting for task to complete."); } } } else { futureToRun.run(); } return futureToRun; }