Skip to content

Instantly share code, notes, and snippets.

@devflow
Created June 8, 2016 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devflow/d4e97ecc258787bae4ac1a0877b314a1 to your computer and use it in GitHub Desktop.
Save devflow/d4e97ecc258787bae4ac1a0877b314a1 to your computer and use it in GitHub Desktop.
android-async-http file array.
Map<String, ArrayList<File>> fileMaps = new HashMap<>();
for (QueryParam queryParam : queryParams) {
if(queryParam == null) continue;
String type = queryParam.type;
if (type.equalsIgnoreCase("string")) {
requestParams.add(queryParam.key, queryParam.val);
} else if (type.equalsIgnoreCase("file")) {
try {
if(!fileMaps.containsKey(queryParam.key)){
fileMaps.put(queryParam.key, new ArrayList<File>());
}
fileMaps.get(queryParam.key).add(new File(queryParam.val));
//requestParams.put(queryParam.key, new File(queryParam.val));
} catch (Exception e) {
e.printStackTrace();
}
}
}
for (String key :
fileMaps.keySet()) {
ArrayList<File> files = fileMaps.get(key);
try {
requestParams.put(key, files.toArray(new File[files.size()]));
}catch (Exception e){
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment