262 lines
12 KiB
Java
262 lines
12 KiB
Java
package com.airbnb.lottie.parser;
|
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Rect;
|
|
import com.airbnb.lottie.LottieComposition;
|
|
import com.airbnb.lottie.model.animatable.AnimatableFloatValue;
|
|
import com.airbnb.lottie.model.animatable.AnimatableTextFrame;
|
|
import com.airbnb.lottie.model.animatable.AnimatableTextProperties;
|
|
import com.airbnb.lottie.model.animatable.AnimatableTransform;
|
|
import com.airbnb.lottie.model.content.BlurEffect;
|
|
import com.airbnb.lottie.model.content.ContentModel;
|
|
import com.airbnb.lottie.model.layer.Layer;
|
|
import com.airbnb.lottie.parser.moshi.JsonReader;
|
|
import com.airbnb.lottie.utils.Utils;
|
|
import com.airbnb.lottie.value.Keyframe;
|
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
import com.kofax.mobile.sdk._internal.impl.extraction.kta.KtaJsonExactionHelper;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class LayerParser {
|
|
private static final JsonReader.Options NAMES = JsonReader.Options.of("nm", "ind", "refId", "ty", "parent", "sw", "sh", "sc", "ks", "tt", "masksProperties", "shapes", "t", "ef", "sr", "st", "w", "h", "ip", "op", "tm", "cl", "hd");
|
|
private static final JsonReader.Options TEXT_NAMES = JsonReader.Options.of(KtaJsonExactionHelper.OBJECT, "a");
|
|
private static final JsonReader.Options EFFECTS_NAMES = JsonReader.Options.of("ty", "nm");
|
|
|
|
private LayerParser() {
|
|
}
|
|
|
|
public static Layer parse(LottieComposition lottieComposition) {
|
|
Rect bounds = lottieComposition.getBounds();
|
|
return new Layer(Collections.emptyList(), lottieComposition, "__container", -1L, Layer.LayerType.PRE_COMP, -1L, null, Collections.emptyList(), new AnimatableTransform(), 0, 0, 0, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, bounds.width(), bounds.height(), null, null, Collections.emptyList(), Layer.MatteType.NONE, null, false, null, null);
|
|
}
|
|
|
|
public static Layer parse(JsonReader jsonReader, LottieComposition lottieComposition) throws IOException {
|
|
ArrayList arrayList;
|
|
ArrayList arrayList2;
|
|
float f;
|
|
Layer.MatteType matteType = Layer.MatteType.NONE;
|
|
ArrayList arrayList3 = new ArrayList();
|
|
ArrayList arrayList4 = new ArrayList();
|
|
jsonReader.beginObject();
|
|
Float valueOf = Float.valueOf(1.0f);
|
|
Float valueOf2 = Float.valueOf(BitmapDescriptorFactory.HUE_RED);
|
|
String str = "UNSET";
|
|
Layer.MatteType matteType2 = matteType;
|
|
float f2 = 1.0f;
|
|
Layer.LayerType layerType = null;
|
|
String str2 = null;
|
|
AnimatableTransform animatableTransform = null;
|
|
AnimatableTextFrame animatableTextFrame = null;
|
|
AnimatableTextProperties animatableTextProperties = null;
|
|
AnimatableFloatValue animatableFloatValue = null;
|
|
BlurEffect blurEffect = null;
|
|
DropShadowEffect dropShadowEffect = null;
|
|
long j = 0;
|
|
int i = 0;
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
int i5 = 0;
|
|
boolean z = false;
|
|
float f3 = 0.0f;
|
|
float f4 = 0.0f;
|
|
long j2 = -1;
|
|
String str3 = null;
|
|
float f5 = 0.0f;
|
|
while (jsonReader.hasNext()) {
|
|
switch (jsonReader.selectName(NAMES)) {
|
|
case 0:
|
|
str = jsonReader.nextString();
|
|
break;
|
|
case 1:
|
|
j = jsonReader.nextInt();
|
|
break;
|
|
case 2:
|
|
str2 = jsonReader.nextString();
|
|
break;
|
|
case 3:
|
|
int nextInt = jsonReader.nextInt();
|
|
if (nextInt < Layer.LayerType.UNKNOWN.ordinal()) {
|
|
layerType = Layer.LayerType.values()[nextInt];
|
|
break;
|
|
} else {
|
|
layerType = Layer.LayerType.UNKNOWN;
|
|
break;
|
|
}
|
|
case 4:
|
|
j2 = jsonReader.nextInt();
|
|
break;
|
|
case 5:
|
|
i = (int) (jsonReader.nextInt() * Utils.dpScale());
|
|
break;
|
|
case 6:
|
|
i2 = (int) (jsonReader.nextInt() * Utils.dpScale());
|
|
break;
|
|
case 7:
|
|
i3 = Color.parseColor(jsonReader.nextString());
|
|
break;
|
|
case 8:
|
|
animatableTransform = AnimatableTransformParser.parse(jsonReader, lottieComposition);
|
|
break;
|
|
case 9:
|
|
int nextInt2 = jsonReader.nextInt();
|
|
if (nextInt2 >= Layer.MatteType.values().length) {
|
|
lottieComposition.addWarning("Unsupported matte type: ".concat(String.valueOf(nextInt2)));
|
|
break;
|
|
} else {
|
|
matteType2 = Layer.MatteType.values()[nextInt2];
|
|
int i6 = AnonymousClass1.$SwitchMap$com$airbnb$lottie$model$layer$Layer$MatteType[matteType2.ordinal()];
|
|
if (i6 == 1) {
|
|
lottieComposition.addWarning("Unsupported matte type: Luma");
|
|
} else if (i6 == 2) {
|
|
lottieComposition.addWarning("Unsupported matte type: Luma Inverted");
|
|
}
|
|
lottieComposition.incrementMatteOrMaskCount(1);
|
|
break;
|
|
}
|
|
case 10:
|
|
jsonReader.beginArray();
|
|
while (jsonReader.hasNext()) {
|
|
arrayList3.add(MaskParser.parse(jsonReader, lottieComposition));
|
|
}
|
|
lottieComposition.incrementMatteOrMaskCount(arrayList3.size());
|
|
jsonReader.endArray();
|
|
break;
|
|
case 11:
|
|
jsonReader.beginArray();
|
|
while (jsonReader.hasNext()) {
|
|
ContentModel parse = ContentModelParser.parse(jsonReader, lottieComposition);
|
|
if (parse != null) {
|
|
arrayList4.add(parse);
|
|
}
|
|
}
|
|
jsonReader.endArray();
|
|
break;
|
|
case 12:
|
|
jsonReader.beginObject();
|
|
while (jsonReader.hasNext()) {
|
|
int selectName = jsonReader.selectName(TEXT_NAMES);
|
|
if (selectName == 0) {
|
|
animatableTextFrame = AnimatableValueParser.parseDocumentData(jsonReader, lottieComposition);
|
|
} else if (selectName == 1) {
|
|
jsonReader.beginArray();
|
|
if (jsonReader.hasNext()) {
|
|
animatableTextProperties = AnimatableTextPropertiesParser.parse(jsonReader, lottieComposition);
|
|
}
|
|
while (jsonReader.hasNext()) {
|
|
jsonReader.skipValue();
|
|
}
|
|
jsonReader.endArray();
|
|
} else {
|
|
jsonReader.skipName();
|
|
jsonReader.skipValue();
|
|
}
|
|
}
|
|
jsonReader.endObject();
|
|
break;
|
|
case 13:
|
|
jsonReader.beginArray();
|
|
ArrayList arrayList5 = new ArrayList();
|
|
while (jsonReader.hasNext()) {
|
|
jsonReader.beginObject();
|
|
while (jsonReader.hasNext()) {
|
|
int selectName2 = jsonReader.selectName(EFFECTS_NAMES);
|
|
if (selectName2 == 0) {
|
|
int nextInt3 = jsonReader.nextInt();
|
|
if (nextInt3 == 29) {
|
|
blurEffect = BlurEffectParser.parse(jsonReader, lottieComposition);
|
|
} else if (nextInt3 == 25) {
|
|
dropShadowEffect = new DropShadowEffectParser().parse(jsonReader, lottieComposition);
|
|
}
|
|
} else if (selectName2 == 1) {
|
|
arrayList5.add(jsonReader.nextString());
|
|
} else {
|
|
jsonReader.skipName();
|
|
jsonReader.skipValue();
|
|
}
|
|
}
|
|
jsonReader.endObject();
|
|
}
|
|
jsonReader.endArray();
|
|
lottieComposition.addWarning("Lottie doesn't support layer effects. If you are using them for fills, strokes, trim paths etc. then try adding them directly as contents in your shape. Found: ".concat(String.valueOf(arrayList5)));
|
|
break;
|
|
case 14:
|
|
f2 = (float) jsonReader.nextDouble();
|
|
break;
|
|
case 15:
|
|
f3 = (float) jsonReader.nextDouble();
|
|
break;
|
|
case 16:
|
|
i4 = (int) (jsonReader.nextInt() * Utils.dpScale());
|
|
break;
|
|
case 17:
|
|
i5 = (int) (jsonReader.nextInt() * Utils.dpScale());
|
|
break;
|
|
case 18:
|
|
f5 = (float) jsonReader.nextDouble();
|
|
break;
|
|
case 19:
|
|
f4 = (float) jsonReader.nextDouble();
|
|
break;
|
|
case 20:
|
|
animatableFloatValue = AnimatableValueParser.parseFloat(jsonReader, lottieComposition, false);
|
|
break;
|
|
case 21:
|
|
str3 = jsonReader.nextString();
|
|
break;
|
|
case 22:
|
|
z = jsonReader.nextBoolean();
|
|
break;
|
|
default:
|
|
jsonReader.skipName();
|
|
jsonReader.skipValue();
|
|
break;
|
|
}
|
|
}
|
|
jsonReader.endObject();
|
|
ArrayList arrayList6 = new ArrayList();
|
|
if (f5 > BitmapDescriptorFactory.HUE_RED) {
|
|
arrayList = arrayList3;
|
|
arrayList2 = arrayList6;
|
|
arrayList2.add(new Keyframe(lottieComposition, valueOf2, valueOf2, null, BitmapDescriptorFactory.HUE_RED, Float.valueOf(f5)));
|
|
f = BitmapDescriptorFactory.HUE_RED;
|
|
} else {
|
|
arrayList = arrayList3;
|
|
arrayList2 = arrayList6;
|
|
f = 0.0f;
|
|
}
|
|
if (f4 <= f) {
|
|
f4 = lottieComposition.getEndFrame();
|
|
}
|
|
arrayList2.add(new Keyframe(lottieComposition, valueOf, valueOf, null, f5, Float.valueOf(f4)));
|
|
arrayList2.add(new Keyframe(lottieComposition, valueOf2, valueOf2, null, f4, Float.valueOf(Float.MAX_VALUE)));
|
|
if (str.endsWith(".ai") || "ai".equals(str3)) {
|
|
lottieComposition.addWarning("Convert your Illustrator layers to shape layers.");
|
|
}
|
|
return new Layer(arrayList4, lottieComposition, str, j, layerType, j2, str2, arrayList, animatableTransform, i, i2, i3, f2, f3, i4, i5, animatableTextFrame, animatableTextProperties, arrayList2, matteType2, animatableFloatValue, z, blurEffect, dropShadowEffect);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: com.airbnb.lottie.parser.LayerParser$1, reason: invalid class name */
|
|
/* loaded from: classes.dex */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
static final int[] $SwitchMap$com$airbnb$lottie$model$layer$Layer$MatteType;
|
|
|
|
static {
|
|
int[] iArr = new int[Layer.MatteType.values().length];
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$MatteType = iArr;
|
|
try {
|
|
iArr[Layer.MatteType.LUMA.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$MatteType[Layer.MatteType.LUMA_INVERTED.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
}
|
|
}
|
|
}
|