- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
419 lines
16 KiB
Java
419 lines
16 KiB
Java
package csdk.glucentralservices.eventbus;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.os.Bundle;
|
|
import android.util.JsonReader;
|
|
import android.util.JsonToken;
|
|
import csdk.gluads.Consts;
|
|
import java.io.StringReader;
|
|
import java.lang.reflect.Array;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONStringer;
|
|
|
|
/* loaded from: classes4.dex */
|
|
class CollectionUtil {
|
|
public static final IVisitor<Object> BUILDER_LIST;
|
|
public static final IVisitor<Object> BUILDER_MAP;
|
|
public static final IVisitor<Object> BUILDER_OUTER;
|
|
public static final IVisitor<JSONStringer> JSON_LIST;
|
|
public static final IVisitor<JSONStringer> JSON_MAP;
|
|
public static final IVisitor<JSONStringer> JSON_OUTER;
|
|
|
|
public interface IVisitor<S> {
|
|
Object beginList(S s, Object obj, String str) throws Exception;
|
|
|
|
Object beginMap(S s, Object obj, String str) throws Exception;
|
|
|
|
Object endList(S s, Object obj, String str, Object obj2) throws Exception;
|
|
|
|
Object endMap(S s, Object obj, String str, Object obj2) throws Exception;
|
|
|
|
IVisitor<S> list();
|
|
|
|
IVisitor<S> map();
|
|
|
|
Object val(S s, Object obj, String str, Object obj2) throws Exception;
|
|
}
|
|
|
|
static {
|
|
JSON_MAP = new JSONStringerMapVisitor();
|
|
JSONStringerListVisitor jSONStringerListVisitor = new JSONStringerListVisitor();
|
|
JSON_LIST = jSONStringerListVisitor;
|
|
JSON_OUTER = jSONStringerListVisitor;
|
|
BUILDER_MAP = new BuilderMapVisitor();
|
|
BUILDER_LIST = new BuilderListVisitor();
|
|
BUILDER_OUTER = new BuilderOuterVisitor();
|
|
}
|
|
|
|
public static Map<String, Object> parseJSON(String str) throws JSONException {
|
|
return Api11.parseJsonObject(str);
|
|
}
|
|
|
|
public static Map<String, Object> toMap(Object obj) {
|
|
try {
|
|
return (Map) visit(obj, BUILDER_OUTER, null, null, null);
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
public static String toJSON(Object obj) throws JSONException {
|
|
JSONStringer jSONStringer = new JSONStringer();
|
|
jsonValue(jSONStringer, obj);
|
|
return jSONStringer.toString();
|
|
}
|
|
|
|
public static void jsonValue(JSONStringer jSONStringer, Object obj) throws JSONException {
|
|
try {
|
|
visit(obj, JSON_OUTER, jSONStringer, null, null);
|
|
} catch (JSONException e) {
|
|
throw e;
|
|
} catch (Exception e2) {
|
|
throw new RuntimeException(e2);
|
|
}
|
|
}
|
|
|
|
public static <S> Object visit(Object obj, IVisitor<S> iVisitor, S s, Object obj2, String str) throws Exception {
|
|
if (obj == null || (obj instanceof Number) || (obj instanceof Boolean)) {
|
|
return iVisitor.val(s, obj2, str, obj);
|
|
}
|
|
if ((obj instanceof CharSequence) || (obj instanceof Character)) {
|
|
return iVisitor.val(s, obj2, str, obj.toString());
|
|
}
|
|
if (obj instanceof Map) {
|
|
return visitMap(iVisitor, s, obj2, str, (Map) obj);
|
|
}
|
|
if (obj instanceof Iterable) {
|
|
IVisitor<S> list = iVisitor.list();
|
|
Object beginList = iVisitor.beginList(s, obj2, str);
|
|
Iterator it = ((Iterable) obj).iterator();
|
|
while (it.hasNext()) {
|
|
beginList = visit(it.next(), list, s, beginList, null);
|
|
}
|
|
return iVisitor.endList(s, obj2, str, beginList);
|
|
}
|
|
int i = 0;
|
|
if (obj.getClass().isArray()) {
|
|
IVisitor<S> list2 = iVisitor.list();
|
|
Object beginList2 = iVisitor.beginList(s, obj2, str);
|
|
int length = Array.getLength(obj);
|
|
while (i < length) {
|
|
beginList2 = visit(Array.get(obj, i), list2, s, beginList2, null);
|
|
i++;
|
|
}
|
|
return iVisitor.endList(s, obj2, str, beginList2);
|
|
}
|
|
if (obj instanceof Bundle) {
|
|
IVisitor<S> map = iVisitor.map();
|
|
Object beginMap = iVisitor.beginMap(s, obj2, str);
|
|
Bundle bundle = (Bundle) obj;
|
|
Iterator<String> it2 = bundle.keySet().iterator();
|
|
while (it2.hasNext()) {
|
|
beginMap = visit(bundle.get(str), map, s, beginMap, it2.next());
|
|
}
|
|
return iVisitor.endMap(s, obj2, str, beginMap);
|
|
}
|
|
if (obj instanceof JSONArray) {
|
|
IVisitor<S> list3 = iVisitor.list();
|
|
Object beginList3 = iVisitor.beginList(s, obj2, str);
|
|
JSONArray jSONArray = (JSONArray) obj;
|
|
while (i < jSONArray.length()) {
|
|
beginList3 = visit(jSONArray.opt(i), list3, s, beginList3, null);
|
|
i++;
|
|
}
|
|
return iVisitor.endList(s, obj2, str, beginList3);
|
|
}
|
|
if (obj instanceof JSONObject) {
|
|
IVisitor<S> map2 = iVisitor.map();
|
|
Object beginMap2 = iVisitor.beginMap(s, obj2, str);
|
|
JSONObject jSONObject = (JSONObject) obj;
|
|
Iterator<String> keys = jSONObject.keys();
|
|
while (keys.hasNext()) {
|
|
beginMap2 = visit(jSONObject.opt(str), map2, s, beginMap2, keys.next());
|
|
}
|
|
return iVisitor.endMap(s, obj2, str, beginMap2);
|
|
}
|
|
if (obj == JSONObject.NULL) {
|
|
return iVisitor.val(s, obj2, str, null);
|
|
}
|
|
IVisitor<S> map3 = iVisitor.map();
|
|
Object visit = visit(obj.getClass().getSimpleName(), map3, s, iVisitor.beginMap(s, obj2, str), "cls");
|
|
String collectionUtil = toString(obj);
|
|
if (collectionUtil != null) {
|
|
visit = visit(collectionUtil, map3, s, visit, "str");
|
|
}
|
|
return iVisitor.endMap(s, obj2, str, visit);
|
|
}
|
|
|
|
private static <S> Object visitMap(IVisitor<S> iVisitor, S s, Object obj, String str, Map<?, ?> map) throws Exception {
|
|
Iterator<?> it = map.keySet().iterator();
|
|
while (it.hasNext()) {
|
|
if (!(it.next() instanceof CharSequence)) {
|
|
return visitMapWithNonStringKeys(iVisitor, s, obj, str, map);
|
|
}
|
|
}
|
|
IVisitor<S> map2 = iVisitor.map();
|
|
Object beginMap = iVisitor.beginMap(s, obj, str);
|
|
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
|
beginMap = visit(entry.getValue(), map2, s, beginMap, entry.getKey().toString());
|
|
}
|
|
return iVisitor.endMap(s, obj, str, beginMap);
|
|
}
|
|
|
|
private static <S> Object visitMapWithNonStringKeys(IVisitor<S> iVisitor, S s, Object obj, String str, Map<?, ?> map) throws Exception {
|
|
IVisitor<S> map2 = iVisitor.map();
|
|
Object visit = visit("flatmap", map2, s, iVisitor.beginMap(s, obj, str), "cls");
|
|
IVisitor<S> list = iVisitor.list();
|
|
Object beginList = map2.beginList(s, visit, Consts.KEY_TAPJOY_USER_ID_VERSION);
|
|
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
|
visit(entry.getKey(), list, s, beginList, null);
|
|
visit(entry.getValue(), list, s, beginList, null);
|
|
}
|
|
map2.endList(s, visit, Consts.KEY_TAPJOY_USER_ID_VERSION, beginList);
|
|
return iVisitor.endMap(s, obj, str, visit);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static <K, V> Map<K, V> createMap() {
|
|
return new HashMap();
|
|
}
|
|
|
|
private static String toString(Object obj) {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
if (obj instanceof Throwable) {
|
|
return ((Throwable) obj).getMessage();
|
|
}
|
|
return obj.toString();
|
|
}
|
|
|
|
public static abstract class JSONStringerBaseVisitor implements IVisitor<JSONStringer> {
|
|
private JSONStringerBaseVisitor() {
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object endMap(JSONStringer jSONStringer, Object obj, String str, Object obj2) throws JSONException {
|
|
return jSONStringer.endObject();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object endList(JSONStringer jSONStringer, Object obj, String str, Object obj2) throws JSONException {
|
|
return jSONStringer.endArray();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public IVisitor<JSONStringer> map() {
|
|
return CollectionUtil.JSON_MAP;
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public IVisitor<JSONStringer> list() {
|
|
return CollectionUtil.JSON_LIST;
|
|
}
|
|
}
|
|
|
|
public static class JSONStringerMapVisitor extends JSONStringerBaseVisitor {
|
|
private JSONStringerMapVisitor() {
|
|
super();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginMap(JSONStringer jSONStringer, Object obj, String str) throws JSONException {
|
|
return jSONStringer.key(str).object();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginList(JSONStringer jSONStringer, Object obj, String str) throws JSONException {
|
|
return jSONStringer.key(str).array();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object val(JSONStringer jSONStringer, Object obj, String str, Object obj2) throws JSONException {
|
|
return jSONStringer.key(str).value(obj2);
|
|
}
|
|
}
|
|
|
|
public static class JSONStringerListVisitor extends JSONStringerBaseVisitor {
|
|
private JSONStringerListVisitor() {
|
|
super();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginMap(JSONStringer jSONStringer, Object obj, String str) throws JSONException {
|
|
return jSONStringer.object();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginList(JSONStringer jSONStringer, Object obj, String str) throws JSONException {
|
|
return jSONStringer.array();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object val(JSONStringer jSONStringer, Object obj, String str, Object obj2) throws JSONException {
|
|
return jSONStringer.value(obj2);
|
|
}
|
|
}
|
|
|
|
public static abstract class BuilderBaseVisitor implements IVisitor<Object> {
|
|
private BuilderBaseVisitor() {
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginMap(Object obj, Object obj2, String str) {
|
|
return CollectionUtil.createMap();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object endMap(Object obj, Object obj2, String str, Object obj3) throws Exception {
|
|
return val(obj, obj2, str, obj3);
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object beginList(Object obj, Object obj2, String str) {
|
|
return new ArrayList();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object endList(Object obj, Object obj2, String str, Object obj3) throws Exception {
|
|
return val(obj, obj2, str, obj3);
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public IVisitor<Object> map() {
|
|
return CollectionUtil.BUILDER_MAP;
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public IVisitor<Object> list() {
|
|
return CollectionUtil.BUILDER_LIST;
|
|
}
|
|
}
|
|
|
|
public static class BuilderMapVisitor extends BuilderBaseVisitor {
|
|
private BuilderMapVisitor() {
|
|
super();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object val(Object obj, Object obj2, String str, Object obj3) {
|
|
Map map = (Map) obj2;
|
|
map.put(str, obj3);
|
|
return map;
|
|
}
|
|
}
|
|
|
|
public static class BuilderListVisitor extends BuilderBaseVisitor {
|
|
private BuilderListVisitor() {
|
|
super();
|
|
}
|
|
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object val(Object obj, Object obj2, String str, Object obj3) {
|
|
List list = (List) obj2;
|
|
list.add(obj3);
|
|
return list;
|
|
}
|
|
}
|
|
|
|
public static class BuilderOuterVisitor extends BuilderBaseVisitor {
|
|
@Override // csdk.glucentralservices.eventbus.CollectionUtil.IVisitor
|
|
public Object val(Object obj, Object obj2, String str, Object obj3) {
|
|
return obj3;
|
|
}
|
|
|
|
private BuilderOuterVisitor() {
|
|
super();
|
|
}
|
|
}
|
|
|
|
@TargetApi(11)
|
|
public static class Api11 {
|
|
public static Map<String, Object> parseJsonObject(String str) throws JSONException {
|
|
return (Map) parseJsonValue(str, CollectionUtil.BUILDER_OUTER, null);
|
|
}
|
|
|
|
public static <S> Object parseJsonValue(String str, IVisitor<S> iVisitor, S s) throws JSONException {
|
|
try {
|
|
JsonReader jsonReader = new JsonReader(new StringReader(str));
|
|
jsonReader.setLenient(true);
|
|
return parseJsonValue(jsonReader, iVisitor, s, null, null);
|
|
} catch (JSONException e) {
|
|
throw e;
|
|
} catch (Exception e2) {
|
|
throw new RuntimeException(e2);
|
|
}
|
|
}
|
|
|
|
public static <S> Object parseJsonValue(JsonReader jsonReader, IVisitor<S> iVisitor, S s, Object obj, String str) throws Exception {
|
|
JsonToken peek = jsonReader.peek();
|
|
if (peek == JsonToken.BEGIN_OBJECT) {
|
|
return parseJsonObject(jsonReader, iVisitor, s, obj, str);
|
|
}
|
|
if (peek == JsonToken.BEGIN_ARRAY) {
|
|
return parseJsonArray(jsonReader, iVisitor, s, obj, str);
|
|
}
|
|
if (peek == JsonToken.BOOLEAN) {
|
|
return iVisitor.val(s, obj, str, Boolean.valueOf(jsonReader.nextBoolean()));
|
|
}
|
|
if (peek == JsonToken.NULL) {
|
|
jsonReader.nextNull();
|
|
return iVisitor.val(s, obj, str, null);
|
|
}
|
|
if (peek == JsonToken.NUMBER) {
|
|
String nextString = jsonReader.nextString();
|
|
if (nextString.contains(Consts.STRING_PERIOD) || nextString.contains("e") || nextString.contains("E")) {
|
|
return iVisitor.val(s, obj, str, Double.valueOf(Double.parseDouble(nextString)));
|
|
}
|
|
return iVisitor.val(s, obj, str, Long.valueOf(Long.parseLong(nextString)));
|
|
}
|
|
if (peek == JsonToken.STRING) {
|
|
return iVisitor.val(s, obj, str, jsonReader.nextString());
|
|
}
|
|
throw new JSONException("Unexpected token " + peek);
|
|
}
|
|
|
|
public static <S> Object parseJsonObject(JsonReader jsonReader, IVisitor<S> iVisitor, S s, Object obj, String str) throws Exception {
|
|
jsonReader.beginObject();
|
|
IVisitor<S> map = iVisitor.map();
|
|
Object beginMap = iVisitor.beginMap(s, obj, str);
|
|
while (true) {
|
|
JsonToken peek = jsonReader.peek();
|
|
if (peek == JsonToken.END_OBJECT) {
|
|
jsonReader.endObject();
|
|
return iVisitor.endMap(s, obj, str, beginMap);
|
|
}
|
|
if (peek == JsonToken.NAME) {
|
|
beginMap = parseJsonValue(jsonReader, map, s, beginMap, jsonReader.nextName());
|
|
} else {
|
|
throw new JSONException("Expected } or name but found " + peek);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static <S> Object parseJsonArray(JsonReader jsonReader, IVisitor<S> iVisitor, S s, Object obj, String str) throws Exception {
|
|
jsonReader.beginArray();
|
|
IVisitor<S> list = iVisitor.list();
|
|
Object beginList = iVisitor.beginList(s, obj, str);
|
|
while (jsonReader.peek() != JsonToken.END_ARRAY) {
|
|
beginList = parseJsonValue(jsonReader, list, s, beginList, null);
|
|
}
|
|
jsonReader.endArray();
|
|
return iVisitor.endList(s, obj, str, beginList);
|
|
}
|
|
}
|
|
|
|
public static class Api1 {
|
|
public static Map<String, Object> parseJsonObject(String str) throws JSONException {
|
|
return CollectionUtil.toMap(new JSONObject(str));
|
|
}
|
|
}
|
|
}
|