22
22
import org .json .JSONException ;
23
23
import org .json .JSONObject ;
24
24
import org .json .JSONTokener ;
25
-
25
+ import org . apache . http . Header ;
26
26
import android .os .Message ;
27
27
28
28
/**
@@ -68,7 +68,7 @@ public void onSuccess(JSONArray response) {}
68
68
* @param statusCode the status code of the response
69
69
* @param response the parsed json object found in the server response (if any)
70
70
*/
71
- public void onSuccess (int statusCode , JSONObject response ) {
71
+ public void onSuccess (int statusCode , Header [] headers , JSONObject response ) {
72
72
onSuccess (response );
73
73
}
74
74
@@ -80,7 +80,7 @@ public void onSuccess(int statusCode, JSONObject response) {
80
80
* @param statusCode the status code of the response
81
81
* @param response the parsed json array found in the server response (if any)
82
82
*/
83
- public void onSuccess (int statusCode , JSONArray response ) {
83
+ public void onSuccess (int statusCode , Header [] headers , JSONArray response ) {
84
84
onSuccess (response );
85
85
}
86
86
@@ -93,10 +93,10 @@ public void onFailure(Throwable e, JSONArray errorResponse) {}
93
93
//
94
94
95
95
@ Override
96
- protected void sendSuccessMessage (int statusCode , String responseBody ) {
96
+ protected void sendSuccessMessage (int statusCode , Header [] headers , String responseBody ) {
97
97
try {
98
98
Object jsonResponse = parseResponse (responseBody );
99
- sendMessage (obtainMessage (SUCCESS_JSON_MESSAGE , new Object []{statusCode , jsonResponse }));
99
+ sendMessage (obtainMessage (SUCCESS_JSON_MESSAGE , new Object []{statusCode , headers , jsonResponse }));
100
100
} catch (JSONException e ) {
101
101
sendFailureMessage (e , responseBody );
102
102
}
@@ -112,18 +112,18 @@ protected void handleMessage(Message msg) {
112
112
switch (msg .what ){
113
113
case SUCCESS_JSON_MESSAGE :
114
114
Object [] response = (Object []) msg .obj ;
115
- handleSuccessJsonMessage (((Integer ) response [0 ]).intValue (), response [1 ]);
115
+ handleSuccessJsonMessage (((Integer ) response [0 ]).intValue (),( Header []) response [1 ] , response [ 2 ]);
116
116
break ;
117
117
default :
118
118
super .handleMessage (msg );
119
119
}
120
120
}
121
121
122
- protected void handleSuccessJsonMessage (int statusCode , Object jsonResponse ) {
122
+ protected void handleSuccessJsonMessage (int statusCode ,Header [] headers , Object jsonResponse ) {
123
123
if (jsonResponse instanceof JSONObject ) {
124
- onSuccess (statusCode , (JSONObject )jsonResponse );
124
+ onSuccess (statusCode , headers , (JSONObject )jsonResponse );
125
125
} else if (jsonResponse instanceof JSONArray ) {
126
- onSuccess (statusCode , (JSONArray )jsonResponse );
126
+ onSuccess (statusCode , headers , (JSONArray )jsonResponse );
127
127
} else {
128
128
onFailure (new JSONException ("Unexpected type " + jsonResponse .getClass ().getName ()), (JSONObject )null );
129
129
}
0 commit comments