Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 262d88a

Browse files
committed
Move methods so they are consistent with asynchttpresponsehandler
1 parent 9f8c301 commit 262d88a

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

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

+22-17
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,29 @@ public void onSuccess(JSONObject response) {}
6161
*/
6262
public void onSuccess(JSONArray response) {}
6363

64+
public void onFailure(Throwable e, JSONObject errorResponse) {}
65+
public void onFailure(Throwable e, JSONArray errorResponse) {}
66+
67+
68+
//
69+
// Pre-processing of messages (executes in background threadpool thread)
70+
//
71+
72+
@Override
73+
protected void sendSuccessMessage(String responseBody) {
74+
try {
75+
Object jsonResponse = parseResponse(responseBody);
76+
sendMessage(obtainMessage(SUCCESS_JSON_MESSAGE, jsonResponse));
77+
} catch(JSONException e) {
78+
sendFailureMessage(e, responseBody);
79+
}
80+
}
81+
82+
83+
//
84+
// Pre-processing of messages (in original calling thread, typically the UI thread)
85+
//
6486

65-
// Utility methods
6687
@Override
6788
protected void handleMessage(Message msg) {
6889
switch(msg.what){
@@ -84,26 +105,10 @@ protected void handleSuccessJsonMessage(Object jsonResponse) {
84105
}
85106
}
86107

87-
@Override
88-
protected void sendSuccessMessage(String responseBody) {
89-
try {
90-
Object jsonResponse = parseResponse(responseBody);
91-
sendMessage(obtainMessage(SUCCESS_JSON_MESSAGE, jsonResponse));
92-
} catch(JSONException e) {
93-
sendFailureMessage(e, responseBody);
94-
}
95-
}
96-
97108
protected Object parseResponse(String responseBody) throws JSONException {
98109
return new JSONTokener(responseBody).nextValue();
99110
}
100111

101-
/**
102-
* Handle cases where a failure is returned as JSON
103-
*/
104-
public void onFailure(Throwable e, JSONObject errorResponse) {}
105-
public void onFailure(Throwable e, JSONArray errorResponse) {}
106-
107112
@Override
108113
protected void handleFailureMessage(Throwable e, String responseBody) {
109114
if (responseBody != null) try {

0 commit comments

Comments
 (0)