Skip to content

Commit 96ceca3

Browse files
committed
Add RequestParams#add
This is a shortcut for adding a parameter which can have many values; useful for communicating for something like Rails, where array parameters are non-unique.
1 parent 874c175 commit 96ceca3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ public void put(String key, ArrayList<String> values) {
142142
}
143143
}
144144

145+
/**
146+
* Adds value to param which can have more than one value.
147+
* @param key the key name for the param, either existing or new.
148+
* @param value
149+
*/
150+
public void add(String key, String value) {
151+
if(key != null && value != null) {
152+
ArrayList<String> paramArray = urlParamsWithArray.get(key);
153+
if (paramArray == null) {
154+
paramArray = new ArrayList<String>();
155+
urlParamsWithArray.put(key, paramArray);
156+
}
157+
paramArray.add(value);
158+
}
159+
}
160+
145161
/**
146162
* Adds an input stream to the request.
147163
* @param key the key name for the new param.

0 commit comments

Comments
 (0)