Skip to content

Commit e3753a8

Browse files
committed
Manually merged android-async-http#492
1 parent 4f40cac commit e3753a8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ protected void sendMessage(Message msg) {
320320
*/
321321
protected void postRunnable(Runnable runnable) {
322322
boolean missingLooper = null == Looper.myLooper();
323-
if (missingLooper) {
324-
Looper.prepare();
325-
}
326-
if (null != runnable) {
327-
handler.post(runnable);
328-
}
329-
if (missingLooper) {
330-
Looper.loop();
323+
if (runnable != null) {
324+
if (missingLooper) {
325+
// If there is no looper, run on current thread
326+
runnable.run();
327+
} else {
328+
// Otherwise, run on a handler we create
329+
handler.post(runnable);
330+
}
331331
}
332332
}
333333

0 commit comments

Comments
 (0)