File tree 1 file changed +18
-0
lines changed
src/com/loopj/android/http
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,24 @@ public RequestParams(String key, String value) {
90
90
put (key , value );
91
91
}
92
92
93
+ /**
94
+ * Constructs a new RequestParams instance and populate it with multiple
95
+ * initial key/value string param.
96
+ * @param keysAndValues a sequence of keys and values. Objects are
97
+ * automatically converted to Strings (including the value {@code null}).
98
+ * @throws IllegalArgumentException if the number of arguments isn't even.
99
+ */
100
+ public RequestParams (Object ... keysAndValues ) {
101
+ int len = keysAndValues .length ;
102
+ if (len % 2 != 0 )
103
+ throw new IllegalArgumentException ("Supplied arguments must be even" );
104
+ for (int i = 0 ; i < len ; i += 2 ) {
105
+ String key = String .valueOf (keysAndValues [i ]);
106
+ String val = String .valueOf (keysAndValues [i + 1 ]);
107
+ put (key , val );
108
+ }
109
+ }
110
+
93
111
/**
94
112
* Adds a key/value string pair to the request.
95
113
* @param key the key name for the new param.
You can’t perform that action at this time.
0 commit comments