-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParams.java
More file actions
51 lines (43 loc) · 1.53 KB
/
Params.java
File metadata and controls
51 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package io.audd.example.utility;
import android.text.TextUtils;
import android.util.ArrayMap;
import java.net.URLEncoder;
import java.util.Map.Entry;
import org.json.JSONException;
import org.json.JSONObject;
public class Params {
private final ArrayMap<String, String> params = new ArrayMap();
public Params addValue(String name, Object value) {
this.params.put(name, String.valueOf(value));
return this;
}
public boolean containsKey(String key) {
return this.params.containsKey(key);
}
public boolean containsValue(String value) {
return this.params.containsValue(value);
}
public JSONObject toJSONObject() throws JSONException {
JSONObject result = new JSONObject();
try {
for (Entry<String, String> entry : this.params.entrySet()) {
result.put((String) entry.getKey(), URLEncoder.encode((String) entry.getValue(), "utf-8"));
}
} catch (Throwable th) {
}
return result;
}
public static Params newInstance() {
return new Params();
}
public String toString() {
String result = "";
try {
for (Entry<String, String> entry : this.params.entrySet()) {
result = result + "&" + ((String) entry.getKey()) + "=" + URLEncoder.encode((String) entry.getValue(), "utf-8");
}
} catch (Throwable th) {
}
return TextUtils.isEmpty(result) ? "from_android=1" : String.valueOf(result.subSequence(1, result.length()));
}
}