Skip to content

Commit 05ed9ce

Browse files
committed
Fixed unchecked cast warning of Iterator
1 parent 16be4c9 commit 05ed9ce

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
package com.loopj.android.http.sample;
2020

2121
import android.util.Log;
22+
2223
import com.loopj.android.http.AsyncHttpClient;
2324
import com.loopj.android.http.RequestHandle;
2425
import com.loopj.android.http.RequestParams;
2526
import com.loopj.android.http.ResponseHandlerInterface;
26-
import java.util.Iterator;
2727

2828
import org.apache.http.Header;
2929
import org.apache.http.HttpEntity;
3030
import org.json.JSONException;
3131
import org.json.JSONObject;
3232

33+
import java.util.Iterator;
34+
3335
/**
3436
* This sample demonstrates how to upload JSON data using streams, resulting
3537
* in a low-memory footprint even with extremely large data.
@@ -52,10 +54,10 @@ public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[]
5254
JSONObject body;
5355
if (isRequestBodyAllowed() && (body = getBodyTextAsJSON()) != null) {
5456
try {
55-
Iterator<String> keys = body.keys();
57+
Iterator keys = body.keys();
5658
Log.d(LOG_TAG, "JSON data:");
5759
while (keys.hasNext()) {
58-
String key = keys.next();
60+
String key = (String) keys.next();
5961
Log.d(LOG_TAG, " " + key + ": " + body.get(key));
6062
params.put(key, body.get(key).toString());
6163
}
@@ -64,7 +66,7 @@ public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[]
6466
}
6567
}
6668
return client.post(this, URL, headers, params,
67-
RequestParams.APPLICATION_JSON, responseHandler);
69+
RequestParams.APPLICATION_JSON, responseHandler);
6870
}
6971

7072
@Override
@@ -88,7 +90,7 @@ protected JSONObject getBodyTextAsJSON() {
8890
if (bodyText != null) {
8991
try {
9092
return new JSONObject(bodyText);
91-
} catch(JSONException e) {
93+
} catch (JSONException e) {
9294
Log.e(LOG_TAG, "User's data is not a valid JSON object", e);
9395
}
9496
}

0 commit comments

Comments
 (0)