Skip to content

Commit b212512

Browse files
committed
Source formatting, curly brackets fixup
1 parent ab8bda4 commit b212512

11 files changed

+67
-55
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,11 @@ private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponse
202202
// Fix to SSL flaw in API < ICS
203203
// See https://code.google.com/p/android/issues/detail?id=13117
204204
SSLSocketFactory sslSocketFactory;
205-
if (fixNoHttpResponseException)
205+
if (fixNoHttpResponseException) {
206206
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
207-
else
207+
} else {
208208
sslSocketFactory = SSLSocketFactory.getSocketFactory();
209+
}
209210

210211
SchemeRegistry schemeRegistry = new SchemeRegistry();
211212
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
@@ -472,9 +473,9 @@ public int getTimeout() {
472473
* Set both the connection and socket timeouts. By default, both are set to
473474
* 10 seconds.
474475
*
475-
* @see If you need further refinement for either value, you can use {@link #setConnectTimeout(int)}
476-
* or {@link #setResponseTimeout(int)} methods.
477476
* @param value the connect/socket timeout in milliseconds, at least 1 second
477+
* @see {@link #setConnectTimeout(int)} if you need further refinement for either value or
478+
* or {@link #setResponseTimeout(int)} methods.
478479
*/
479480
public void setTimeout(int value) {
480481
value = value < 1000 ? DEFAULT_SOCKET_TIMEOUT : value;
@@ -1287,10 +1288,11 @@ private HttpEntity paramsToEntity(RequestParams params, ResponseHandlerInterface
12871288
entity = params.getEntity(responseHandler);
12881289
}
12891290
} catch (IOException e) {
1290-
if (responseHandler != null)
1291+
if (responseHandler != null) {
12911292
responseHandler.sendFailureMessage(0, null, null, e);
1292-
else
1293+
} else {
12931294
e.printStackTrace();
1295+
}
12941296
}
12951297

12961298
return entity;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ private void makeRequest() throws IOException {
146146

147147
HttpResponse response = client.execute(request, context);
148148

149-
if(isCancelled()) {
149+
if (isCancelled()) {
150150
return;
151151
}
152152

153153
if (responseHandler != null) {
154154
// Carry out pre-processing for this response.
155155
responseHandler.onPreProcessResponse(responseHandler, response);
156156

157-
if(isCancelled()) {
157+
if (isCancelled()) {
158158
return;
159159
}
160160

161161
// The response is ready, handle it.
162162
responseHandler.sendResponseMessage(response);
163163

164-
if(isCancelled()) {
164+
if (isCancelled()) {
165165
return;
166166
}
167167

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@ protected void handleMessage(Message message) {
330330
break;
331331
case RETRY_MESSAGE:
332332
response = (Object[]) message.obj;
333-
if (response != null && response.length == 1)
333+
if (response != null && response.length == 1) {
334334
onRetry((Integer) response[0]);
335-
else
335+
} else {
336336
Log.e(LOG_TAG, "RETRY_MESSAGE didn't get enough params");
337+
}
337338
break;
338339
case CANCEL_MESSAGE:
339340
onCancel();

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ public void run() {
9797
}
9898
}
9999
};
100-
if (!getUseSynchronousMode())
100+
if (!getUseSynchronousMode()) {
101101
new Thread(parser).start();
102-
else // In synchronous mode everything should be run on one thread
102+
} else {
103+
// In synchronous mode everything should be run on one thread
103104
parser.run();
105+
}
104106
} else {
105107
onSuccess(statusCode, headers, null, null);
106108
}
@@ -131,10 +133,12 @@ public void run() {
131133
}
132134
}
133135
};
134-
if (!getUseSynchronousMode())
136+
if (!getUseSynchronousMode()) {
135137
new Thread(parser).start();
136-
else // In synchronous mode everything should be run on one thread
138+
} else {
139+
// In synchronous mode everything should be run on one thread
137140
parser.run();
141+
}
138142
} else {
139143
onFailure(statusCode, headers, throwable, null, null);
140144
}

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public abstract class BinaryHttpResponseHandler extends AsyncHttpResponseHandler
5353

5454
private static final String LOG_TAG = "BinaryHttpResponseHandler";
5555

56-
private String[] mAllowedContentTypes = new String[] {
57-
RequestParams.APPLICATION_OCTET_STREAM,
58-
"image/jpeg",
59-
"image/png",
60-
"image/gif"
56+
private String[] mAllowedContentTypes = new String[]{
57+
RequestParams.APPLICATION_OCTET_STREAM,
58+
"image/jpeg",
59+
"image/png",
60+
"image/gif"
6161
};
6262

6363
/**
@@ -85,10 +85,11 @@ public BinaryHttpResponseHandler() {
8585
*/
8686
public BinaryHttpResponseHandler(String[] allowedContentTypes) {
8787
super();
88-
if (allowedContentTypes != null)
88+
if (allowedContentTypes != null) {
8989
mAllowedContentTypes = allowedContentTypes;
90-
else
90+
} else {
9191
Log.e(LOG_TAG, "Constructor passed allowedContentTypes was null !");
92+
}
9293
}
9394

9495
@Override
@@ -104,13 +105,13 @@ public final void sendResponseMessage(HttpResponse response) throws IOException
104105
if (contentTypeHeaders.length != 1) {
105106
//malformed/ambiguous HTTP Header, ABORT!
106107
sendFailureMessage(
107-
status.getStatusCode(),
108-
response.getAllHeaders(),
109-
null,
110-
new HttpResponseException(
111108
status.getStatusCode(),
112-
"None, or more than one, Content-Type Header found!"
113-
)
109+
response.getAllHeaders(),
110+
null,
111+
new HttpResponseException(
112+
status.getStatusCode(),
113+
"None, or more than one, Content-Type Header found!"
114+
)
114115
);
115116
return;
116117
}
@@ -128,13 +129,13 @@ public final void sendResponseMessage(HttpResponse response) throws IOException
128129
if (!foundAllowedContentType) {
129130
//Content-Type not in allowed list, ABORT!
130131
sendFailureMessage(
131-
status.getStatusCode(),
132-
response.getAllHeaders(),
133-
null,
134-
new HttpResponseException(
135132
status.getStatusCode(),
136-
"Content-Type not allowed!"
137-
)
133+
response.getAllHeaders(),
134+
null,
135+
new HttpResponseException(
136+
status.getStatusCode(),
137+
"Content-Type not allowed!"
138+
)
138139
);
139140
return;
140141
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ public void run() {
144144
}
145145
}
146146
};
147-
if (!getUseSynchronousMode())
147+
if (!getUseSynchronousMode()) {
148148
new Thread(parser).start();
149-
else // In synchronous mode everything should be run on one thread
149+
} else {
150+
// In synchronous mode everything should be run on one thread
150151
parser.run();
152+
}
151153
} else {
152154
onSuccess(statusCode, headers, new JSONObject());
153155
}
@@ -187,10 +189,12 @@ public void run() {
187189
}
188190
}
189191
};
190-
if (!getUseSynchronousMode())
192+
if (!getUseSynchronousMode()) {
191193
new Thread(parser).start();
192-
else // In synchronous mode everything should be run on one thread
194+
} else {
195+
// In synchronous mode everything should be run on one thread
193196
parser.run();
197+
}
194198
} else {
195199
Log.v(LOG_TAG, "response body is null, calling onFailure(Throwable, JSONObject)");
196200
onFailure(statusCode, headers, throwable, (JSONObject) null);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public class JsonStreamerEntity implements HttpEntity {
6666

6767
private static final Header HEADER_JSON_CONTENT =
6868
new BasicHeader(
69-
AsyncHttpClient.HEADER_CONTENT_TYPE,
70-
RequestParams.APPLICATION_JSON);
69+
AsyncHttpClient.HEADER_CONTENT_TYPE,
70+
RequestParams.APPLICATION_JSON);
7171

7272
private static final Header HEADER_GZIP_ENCODING =
7373
new BasicHeader(
74-
AsyncHttpClient.HEADER_CONTENT_ENCODING,
75-
AsyncHttpClient.ENCODING_GZIP);
74+
AsyncHttpClient.HEADER_CONTENT_ENCODING,
75+
AsyncHttpClient.ENCODING_GZIP);
7676

7777
// JSON data and associated meta-data to be uploaded.
7878
private final Map<String, Object> jsonParams = new HashMap<String, Object>();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828

2929
import java.io.ByteArrayInputStream;
3030
import java.io.ByteArrayOutputStream;
31+
import java.io.IOException;
3132
import java.io.ObjectInputStream;
3233
import java.io.ObjectOutputStream;
33-
34-
import java.io.IOException;
35-
3634
import java.util.ArrayList;
3735
import java.util.Date;
3836
import java.util.List;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public void sendResponseMessage(HttpResponse response) throws IOException {
6666
if (header == null) {
6767
append = false;
6868
current = 0;
69-
} else
69+
} else {
7070
Log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue());
71+
}
7172
sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity()));
7273
}
7374
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ public class RequestParams {
112112
* @param encoding String constant from {@link org.apache.http.protocol.HTTP}
113113
*/
114114
public void setContentEncoding(final String encoding) {
115-
if (encoding != null)
115+
if (encoding != null) {
116116
this.contentEncoding = encoding;
117-
else
117+
} else {
118118
Log.d(LOG_TAG, "setContentEncoding called with null attribute");
119+
}
119120
}
120121

121122
/**

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ private byte[] createContentType(String type) {
152152

153153
private byte[] createContentDisposition(String key) {
154154
return (
155-
AsyncHttpClient.HEADER_CONTENT_DISPOSITION +
156-
": form-data; name=\"" + key + "\"" + STR_CR_LF).getBytes();
155+
AsyncHttpClient.HEADER_CONTENT_DISPOSITION +
156+
": form-data; name=\"" + key + "\"" + STR_CR_LF).getBytes();
157157
}
158158

159159
private byte[] createContentDisposition(String key, String fileName) {
160160
return (
161-
AsyncHttpClient.HEADER_CONTENT_DISPOSITION +
162-
": form-data; name=\"" + key + "\"" +
163-
"; filename=\"" + fileName + "\"" + STR_CR_LF).getBytes();
161+
AsyncHttpClient.HEADER_CONTENT_DISPOSITION +
162+
": form-data; name=\"" + key + "\"" +
163+
"; filename=\"" + fileName + "\"" + STR_CR_LF).getBytes();
164164
}
165165

166166
private void updateProgress(int count) {
@@ -236,8 +236,8 @@ public long getContentLength() {
236236
@Override
237237
public Header getContentType() {
238238
return new BasicHeader(
239-
AsyncHttpClient.HEADER_CONTENT_TYPE,
240-
"multipart/form-data; boundary=" + boundary);
239+
AsyncHttpClient.HEADER_CONTENT_TYPE,
240+
"multipart/form-data; boundary=" + boundary);
241241
}
242242

243243
@Override

0 commit comments

Comments
 (0)