what-the-bank/sources/com/airbnb/lottie/parser/JsonUtils.java

143 lines
5.5 KiB
Java

package com.airbnb.lottie.parser;
import android.graphics.Color;
import android.graphics.PointF;
import com.airbnb.lottie.parser.moshi.JsonReader;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class JsonUtils {
private static final JsonReader.Options POINT_NAMES = JsonReader.Options.of("x", "y");
private JsonUtils() {
}
/* JADX INFO: Access modifiers changed from: package-private */
public static int jsonToColor(JsonReader jsonReader) throws IOException {
jsonReader.beginArray();
int nextDouble = (int) (jsonReader.nextDouble() * 255.0d);
int nextDouble2 = (int) (jsonReader.nextDouble() * 255.0d);
int nextDouble3 = (int) (jsonReader.nextDouble() * 255.0d);
while (jsonReader.hasNext()) {
jsonReader.skipValue();
}
jsonReader.endArray();
return Color.argb(255, nextDouble, nextDouble2, nextDouble3);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static List<PointF> jsonToPoints(JsonReader jsonReader, float f) throws IOException {
ArrayList arrayList = new ArrayList();
jsonReader.beginArray();
while (jsonReader.peek() == JsonReader.Token.BEGIN_ARRAY) {
jsonReader.beginArray();
arrayList.add(jsonToPoint(jsonReader, f));
jsonReader.endArray();
}
jsonReader.endArray();
return arrayList;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: com.airbnb.lottie.parser.JsonUtils$1, reason: invalid class name */
/* loaded from: classes.dex */
public static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token;
static {
int[] iArr = new int[JsonReader.Token.values().length];
$SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token = iArr;
try {
iArr[JsonReader.Token.NUMBER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token[JsonReader.Token.BEGIN_ARRAY.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token[JsonReader.Token.BEGIN_OBJECT.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static PointF jsonToPoint(JsonReader jsonReader, float f) throws IOException {
int i = AnonymousClass1.$SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token[jsonReader.peek().ordinal()];
if (i == 1) {
return jsonNumbersToPoint(jsonReader, f);
}
if (i == 2) {
return jsonArrayToPoint(jsonReader, f);
}
if (i == 3) {
return jsonObjectToPoint(jsonReader, f);
}
StringBuilder sb = new StringBuilder("Unknown point starts with ");
sb.append(jsonReader.peek());
throw new IllegalArgumentException(sb.toString());
}
private static PointF jsonNumbersToPoint(JsonReader jsonReader, float f) throws IOException {
float nextDouble = (float) jsonReader.nextDouble();
float nextDouble2 = (float) jsonReader.nextDouble();
while (jsonReader.hasNext()) {
jsonReader.skipValue();
}
return new PointF(nextDouble * f, nextDouble2 * f);
}
private static PointF jsonArrayToPoint(JsonReader jsonReader, float f) throws IOException {
jsonReader.beginArray();
float nextDouble = (float) jsonReader.nextDouble();
float nextDouble2 = (float) jsonReader.nextDouble();
while (jsonReader.peek() != JsonReader.Token.END_ARRAY) {
jsonReader.skipValue();
}
jsonReader.endArray();
return new PointF(nextDouble * f, nextDouble2 * f);
}
private static PointF jsonObjectToPoint(JsonReader jsonReader, float f) throws IOException {
jsonReader.beginObject();
float f2 = BitmapDescriptorFactory.HUE_RED;
float f3 = 0.0f;
while (jsonReader.hasNext()) {
int selectName = jsonReader.selectName(POINT_NAMES);
if (selectName == 0) {
f2 = valueFromObject(jsonReader);
} else if (selectName == 1) {
f3 = valueFromObject(jsonReader);
} else {
jsonReader.skipName();
jsonReader.skipValue();
}
}
jsonReader.endObject();
return new PointF(f2 * f, f3 * f);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static float valueFromObject(JsonReader jsonReader) throws IOException {
JsonReader.Token peek = jsonReader.peek();
int i = AnonymousClass1.$SwitchMap$com$airbnb$lottie$parser$moshi$JsonReader$Token[peek.ordinal()];
if (i == 1) {
return (float) jsonReader.nextDouble();
}
if (i == 2) {
jsonReader.beginArray();
float nextDouble = (float) jsonReader.nextDouble();
while (jsonReader.hasNext()) {
jsonReader.skipValue();
}
jsonReader.endArray();
return nextDouble;
}
throw new IllegalArgumentException("Unknown value for token of type ".concat(String.valueOf(peek)));
}
}