Skip to content

Commit ccc1143

Browse files
committed
Fixed many unchecked call warnings during compile time
1 parent dc66f55 commit ccc1143

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class JsonStreamerEntity implements HttpEntity {
7171
new BasicHeader("Content-Encoding", "gzip");
7272

7373
// JSON data and associated meta-data to be uploaded.
74-
private final Map<String, Object> jsonParams = new HashMap();
74+
private final Map<String, Object> jsonParams = new HashMap<String, Object>();
7575

7676
// Whether to use gzip compression while uploading
7777
private final Header contentEncoding;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class PersistentCookieStore implements CookieStore {
6060
*/
6161
public PersistentCookieStore(Context context) {
6262
cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
63-
cookies = new ConcurrentHashMap();
63+
cookies = new ConcurrentHashMap<String, Cookie>();
6464

6565
// Load any previously stored cookies into the store
6666
String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
@@ -146,7 +146,7 @@ public boolean clearExpired(Date date) {
146146

147147
@Override
148148
public List<Cookie> getCookies() {
149-
return new ArrayList(cookies.values());
149+
return new ArrayList<Cookie>(cookies.values());
150150
}
151151

152152
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class RequestHandle {
99
private final WeakReference<AsyncHttpRequest> request;
1010

1111
public RequestHandle(AsyncHttpRequest request) {
12-
this.request = new WeakReference(request);
12+
this.request = new WeakReference<AsyncHttpRequest>(request);
1313
}
1414

1515
/**

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

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@
9090
public class RequestParams {
9191

9292
public final static String APPLICATION_OCTET_STREAM =
93-
"application/octet-stream";
93+
"application/octet-stream";
9494

9595
protected final static String LOG_TAG = "RequestParams";
9696
protected boolean isRepeatable;
9797
protected boolean useJsonStreamer;
9898
protected boolean autoCloseInputStreams;
99-
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap();
100-
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap();
101-
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap();
102-
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap();
99+
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<String, String>();
100+
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<String, StreamWrapper>();
101+
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<String, FileWrapper>();
102+
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
103103
protected String contentEncoding = HTTP.UTF_8;
104104

105105
/**
@@ -307,9 +307,9 @@ public void add(String key, String value) {
307307
this.put(key, params);
308308
}
309309
if (params instanceof List) {
310-
((List) params).add(value);
310+
((List<Object>) params).add(value);
311311
} else if (params instanceof Set) {
312-
((Set) params).add(value);
312+
((Set<Object>) params).add(value);
313313
}
314314
}
315315
}
@@ -334,9 +334,9 @@ public void remove(String key) {
334334
*/
335335
public boolean has(String key) {
336336
return urlParams.get(key) != null ||
337-
streamParams.get(key) != null ||
338-
fileParams.get(key) != null ||
339-
urlParamsWithObjects.get(key) != null;
337+
streamParams.get(key) != null ||
338+
fileParams.get(key) != null ||
339+
urlParamsWithObjects.get(key) != null;
340340
}
341341

342342
@Override
@@ -391,8 +391,8 @@ public void setUseJsonStreamer(boolean useJsonStreamer) {
391391
}
392392

393393
/**
394-
* Set global flag which determines whether to automatically close input
395-
* streams on successful upload.
394+
* Set global flag which determines whether to automatically close input streams on successful
395+
* upload.
396396
*
397397
* @param flag boolean whether to automatically close input streams
398398
*/
@@ -420,7 +420,7 @@ public HttpEntity getEntity(ResponseHandlerInterface progressHandler) throws IOE
420420

421421
private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHandler) throws IOException {
422422
JsonStreamerEntity entity = new JsonStreamerEntity(progressHandler,
423-
!fileParams.isEmpty() || !streamParams.isEmpty());
423+
!fileParams.isEmpty() || !streamParams.isEmpty());
424424

425425
// Add string params
426426
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
@@ -442,11 +442,12 @@ private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHan
442442
StreamWrapper stream = entry.getValue();
443443
if (stream.inputStream != null) {
444444
entity.addPart(entry.getKey(),
445-
StreamWrapper.newInstance(
446-
stream.inputStream,
447-
stream.name,
448-
stream.contentType,
449-
stream.autoClose));
445+
StreamWrapper.newInstance(
446+
stream.inputStream,
447+
stream.name,
448+
stream.contentType,
449+
stream.autoClose)
450+
);
450451
}
451452
}
452453

@@ -496,7 +497,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
496497
}
497498

498499
protected List<BasicNameValuePair> getParamsList() {
499-
List<BasicNameValuePair> lparams = new LinkedList();
500+
List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();
500501

501502
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
502503
lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
@@ -508,12 +509,14 @@ protected List<BasicNameValuePair> getParamsList() {
508509
}
509510

510511
private List<BasicNameValuePair> getParamsList(String key, Object value) {
511-
List<BasicNameValuePair> params = new LinkedList();
512+
List<BasicNameValuePair> params = new LinkedList<BasicNameValuePair>();
512513
if (value instanceof Map) {
513514
Map map = (Map) value;
514515
List list = new ArrayList<Object>(map.keySet());
515516
// Ensure consistent ordering in query string
516-
Collections.sort(list);
517+
if (list.size() > 0 && list.get(0) instanceof Comparable) {
518+
Collections.sort(list);
519+
}
517520
for (Object nestedKey : list) {
518521
if (nestedKey instanceof String) {
519522
Object nestedValue = map.get(nestedKey);
@@ -575,10 +578,10 @@ public StreamWrapper(InputStream inputStream, String name, String contentType, b
575578

576579
static StreamWrapper newInstance(InputStream inputStream, String name, String contentType, boolean autoClose) {
577580
return new StreamWrapper(
578-
inputStream,
579-
name,
580-
contentType == null ? APPLICATION_OCTET_STREAM : contentType,
581-
autoClose);
581+
inputStream,
582+
name,
583+
contentType == null ? APPLICATION_OCTET_STREAM : contentType,
584+
autoClose);
582585
}
583586
}
584587
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import javax.net.ssl.SSLException;
4141

4242
class RetryHandler implements HttpRequestRetryHandler {
43-
private final static HashSet<Class<?>> exceptionWhitelist = new HashSet();
44-
private final static HashSet<Class<?>> exceptionBlacklist = new HashSet();
43+
private final static HashSet<Class<?>> exceptionWhitelist = new HashSet<Class<?>>();
44+
private final static HashSet<Class<?>> exceptionBlacklist = new HashSet<Class<?>>();
4545

4646
static {
4747
// Retry if the server dropped connection on us

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SimpleMultipartEntity implements HttpEntity {
5959
private final byte[] boundaryEnd;
6060
private boolean isRepeatable;
6161

62-
private final List<FilePart> fileParts = new ArrayList();
62+
private final List<FilePart> fileParts = new ArrayList<FilePart>();
6363

6464
// The buffer we use for building the message excluding files and the last
6565
// boundary

0 commit comments

Comments
 (0)