Skip to content

Commit af88795

Browse files
committed
added onSuccess and onFailure methods in GetSample
1 parent e7bce03 commit af88795

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

sample/src/main/java/com/loopj/android/http/sample/GetSample.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.loopj.android.http.sample;
22

3+
import org.apache.http.Header;
4+
35
import com.loopj.android.http.AsyncHttpClient;
46
import com.loopj.android.http.AsyncHttpResponseHandler;
57

68
public class GetSample extends SampleParentActivity {
9+
private static final String LOG_TAG = "GetSample";
710

811
@Override
912
protected void executeSample(AsyncHttpClient client, String URL, AsyncHttpResponseHandler responseHandler) {
@@ -39,6 +42,22 @@ public void onStart() {
3942
clearOutputs();
4043
}
4144

45+
@Override
46+
public void onSuccess(int statusCode, Header[] headers, byte[] response) {
47+
debugHeaders(LOG_TAG, headers);
48+
debugStatusCode(LOG_TAG, statusCode);
49+
debugResponse(LOG_TAG, new String(response));
50+
}
51+
52+
@Override
53+
public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
54+
debugHeaders(LOG_TAG, headers);
55+
debugStatusCode(LOG_TAG, statusCode);
56+
debugThrowable(LOG_TAG, e);
57+
if (errorResponse != null) {
58+
debugResponse(LOG_TAG, new String(errorResponse));
59+
}
60+
}
4261
};
4362
}
4463
}

0 commit comments

Comments
 (0)