Skip to content

Commit 0246825

Browse files
author
Noor Dawod
committed
Small syntax corrections, Javadoc.
1 parent b212512 commit 0246825

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

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

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

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

149-
if (isCancelled()) {
149+
if (isCancelled() || responseHandler == null) {
150150
return;
151151
}
152152

153-
if (responseHandler != null) {
154-
// Carry out pre-processing for this response.
155-
responseHandler.onPreProcessResponse(responseHandler, response);
156-
157-
if (isCancelled()) {
158-
return;
159-
}
153+
// Carry out pre-processing for this response.
154+
responseHandler.onPreProcessResponse(responseHandler, response);
160155

161-
// The response is ready, handle it.
162-
responseHandler.sendResponseMessage(response);
156+
if (isCancelled()) {
157+
return;
158+
}
163159

164-
if (isCancelled()) {
165-
return;
166-
}
160+
// The response is ready, handle it.
161+
responseHandler.sendResponseMessage(response);
167162

168-
// Carry out post-processing for this response.
169-
responseHandler.onPostProcessResponse(responseHandler, response);
163+
if (isCancelled()) {
164+
return;
170165
}
166+
167+
// Carry out post-processing for this response.
168+
responseHandler.onPostProcessResponse(responseHandler, response);
171169
}
172170

173171
private void makeRequestWithRetries() throws IOException {

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ public AsyncHttpResponseHandler() {
186186
}
187187

188188
/**
189-
* Creates a new AsyncHttpResponseHandler
189+
* Creates a new AsyncHttpResponseHandler with a user-supplied looper. If
190+
* the passed looper is null, the looper attached to the current thread will
191+
* be used.
192+
*
193+
* @param looper The looper to work with
190194
*/
191195
public AsyncHttpResponseHandler(Looper looper) {
192196
this.looper = looper == null ? Looper.myLooper() : looper;
@@ -261,30 +265,37 @@ public void onCancel() {
261265
Log.d(LOG_TAG, "Request got cancelled");
262266
}
263267

268+
@Override
264269
final public void sendProgressMessage(int bytesWritten, int bytesTotal) {
265270
sendMessage(obtainMessage(PROGRESS_MESSAGE, new Object[]{bytesWritten, bytesTotal}));
266271
}
267272

273+
@Override
268274
final public void sendSuccessMessage(int statusCode, Header[] headers, byte[] responseBytes) {
269275
sendMessage(obtainMessage(SUCCESS_MESSAGE, new Object[]{statusCode, headers, responseBytes}));
270276
}
271277

278+
@Override
272279
final public void sendFailureMessage(int statusCode, Header[] headers, byte[] responseBody, Throwable throwable) {
273280
sendMessage(obtainMessage(FAILURE_MESSAGE, new Object[]{statusCode, headers, responseBody, throwable}));
274281
}
275282

283+
@Override
276284
final public void sendStartMessage() {
277285
sendMessage(obtainMessage(START_MESSAGE, null));
278286
}
279287

288+
@Override
280289
final public void sendFinishMessage() {
281290
sendMessage(obtainMessage(FINISH_MESSAGE, null));
282291
}
283292

293+
@Override
284294
final public void sendRetryMessage(int retryNo) {
285295
sendMessage(obtainMessage(RETRY_MESSAGE, new Object[]{retryNo}));
286296
}
287297

298+
@Override
288299
final public void sendCancelMessage() {
289300
sendMessage(obtainMessage(CANCEL_MESSAGE, null));
290301
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,5 @@ public interface ResponseHandlerInterface {
154154
* @param instance An instance of this response object
155155
* @param response The response to post-process
156156
*/
157-
public void onPostProcessResponse(ResponseHandlerInterface instance, HttpResponse response);
157+
void onPostProcessResponse(ResponseHandlerInterface instance, HttpResponse response);
158158
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ public void onFailure(int statusCode, Header[] headers, byte[] responseBytes, Th
115115
public static String getResponseString(byte[] stringBytes, String charset) {
116116
try {
117117
String toReturn = (stringBytes == null) ? null : new String(stringBytes, charset);
118-
if (toReturn != null && toReturn.startsWith(UTF8_BOM))
118+
if (toReturn != null && toReturn.startsWith(UTF8_BOM)) {
119119
return toReturn.substring(1);
120+
}
120121
return toReturn;
121122
} catch (UnsupportedEncodingException e) {
122123
Log.e(LOG_TAG, "Encoding response into string failed", e);

0 commit comments

Comments
 (0)