Skip to content

Commit 7178e2c

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 8320517 + 326e53f commit 7178e2c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ public boolean getUseSynchronousMode() {
142142

143143
@Override
144144
public void setUseSynchronousMode(boolean value) {
145-
// Test that a looper has been prepared prior to setting asynchronous mode.
146-
if (value && null == Looper.myLooper()) {
147-
value = false;
148-
Log.i(LOG_TAG, "Current thread has not called Looper.prepare(). Forcing synchronous mode.");
145+
// A looper must be prepared before setting asynchronous mode.
146+
if (!value && Looper.myLooper() == null) {
147+
value = true;
148+
Log.w(LOG_TAG, "Current thread has not called Looper.prepare(). Forcing synchronous mode.");
149149
}
150150

151-
// If using asynchronous mode.
152-
if (value && handler == null) {
151+
// If using synchronous mode.
152+
if (!value && handler == null) {
153153
// Create a handler on current thread to submit tasks
154154
handler = new ResponderHandler(this);
155-
} else if (!value && handler != null) {
155+
} else if (value && handler != null) {
156156
// TODO: Consider adding a flag to remove all queued messages.
157157
handler = null;
158158
}

0 commit comments

Comments
 (0)