274 lines
8.9 KiB
Java
274 lines
8.9 KiB
Java
|
package com.airbnb.lottie;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.Resources;
|
||
|
import android.graphics.Rect;
|
||
|
import com.airbnb.lottie.model.Font;
|
||
|
import com.airbnb.lottie.model.FontCharacter;
|
||
|
import com.airbnb.lottie.model.Marker;
|
||
|
import com.airbnb.lottie.model.layer.Layer;
|
||
|
import com.airbnb.lottie.parser.moshi.JsonReader;
|
||
|
import com.airbnb.lottie.utils.Logger;
|
||
|
import com.airbnb.lottie.utils.MiscUtils;
|
||
|
import java.io.InputStream;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import o.C0667Ltg;
|
||
|
import o.VOL;
|
||
|
import org.json.JSONObject;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public class LottieComposition {
|
||
|
private Rect bounds;
|
||
|
private VOL<FontCharacter> characters;
|
||
|
private float endFrame;
|
||
|
private Map<String, Font> fonts;
|
||
|
private float frameRate;
|
||
|
private boolean hasDashPattern;
|
||
|
private Map<String, LottieImageAsset> images;
|
||
|
private C0667Ltg<Layer> layerMap;
|
||
|
private List<Layer> layers;
|
||
|
private List<Marker> markers;
|
||
|
private Map<String, List<Layer>> precomps;
|
||
|
private float startFrame;
|
||
|
private final PerformanceTracker performanceTracker = new PerformanceTracker();
|
||
|
private final HashSet<String> warnings = new HashSet<>();
|
||
|
private int maskAndMatteCount = 0;
|
||
|
|
||
|
public void addWarning(String str) {
|
||
|
Logger.warning(str);
|
||
|
this.warnings.add(str);
|
||
|
}
|
||
|
|
||
|
public ArrayList<String> getWarnings() {
|
||
|
HashSet<String> hashSet = this.warnings;
|
||
|
return new ArrayList<>(Arrays.asList((String[]) hashSet.toArray(new String[hashSet.size()])));
|
||
|
}
|
||
|
|
||
|
public void setPerformanceTrackingEnabled(boolean z) {
|
||
|
this.performanceTracker.setEnabled(z);
|
||
|
}
|
||
|
|
||
|
public float getDuration() {
|
||
|
return (getDurationFrames() / this.frameRate) * 1000.0f;
|
||
|
}
|
||
|
|
||
|
public float getFrameForProgress(float f) {
|
||
|
return MiscUtils.lerp(this.startFrame, this.endFrame, f);
|
||
|
}
|
||
|
|
||
|
public List<Layer> getPrecomps(String str) {
|
||
|
return this.precomps.get(str);
|
||
|
}
|
||
|
|
||
|
public Marker getMarker(String str) {
|
||
|
int size = this.markers.size();
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
Marker marker = this.markers.get(i);
|
||
|
if (marker.matchesName(str)) {
|
||
|
return marker;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public boolean hasImages() {
|
||
|
return !this.images.isEmpty();
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder sb = new StringBuilder("LottieComposition:\n");
|
||
|
Iterator<Layer> it = this.layers.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
sb.append(it.next().toString("\t"));
|
||
|
}
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
/* loaded from: classes.dex */
|
||
|
public static class Factory {
|
||
|
private Factory() {
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static Cancellable fromAssetFileName(Context context, String str, OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
ListenerAdapter listenerAdapter = new ListenerAdapter(onCompositionLoadedListener);
|
||
|
LottieCompositionFactory.fromAsset(context, str).addListener(listenerAdapter);
|
||
|
return listenerAdapter;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static Cancellable fromRawFile(Context context, int i, OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
ListenerAdapter listenerAdapter = new ListenerAdapter(onCompositionLoadedListener);
|
||
|
LottieCompositionFactory.fromRawRes(context, i).addListener(listenerAdapter);
|
||
|
return listenerAdapter;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static Cancellable fromInputStream(InputStream inputStream, OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
ListenerAdapter listenerAdapter = new ListenerAdapter(onCompositionLoadedListener);
|
||
|
LottieCompositionFactory.fromJsonInputStream(inputStream, null).addListener(listenerAdapter);
|
||
|
return listenerAdapter;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static Cancellable fromJsonString(String str, OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
ListenerAdapter listenerAdapter = new ListenerAdapter(onCompositionLoadedListener);
|
||
|
LottieCompositionFactory.fromJsonString(str, null).addListener(listenerAdapter);
|
||
|
return listenerAdapter;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static Cancellable fromJsonReader(JsonReader jsonReader, OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
ListenerAdapter listenerAdapter = new ListenerAdapter(onCompositionLoadedListener);
|
||
|
LottieCompositionFactory.fromJsonReader(jsonReader, null).addListener(listenerAdapter);
|
||
|
return listenerAdapter;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromFileSync(Context context, String str) {
|
||
|
return LottieCompositionFactory.fromAssetSync(context, str).getValue();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromInputStreamSync(InputStream inputStream) {
|
||
|
return LottieCompositionFactory.fromJsonInputStreamSync(inputStream, null).getValue();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromInputStreamSync(InputStream inputStream, boolean z) {
|
||
|
if (z) {
|
||
|
Logger.warning("Lottie now auto-closes input stream!");
|
||
|
}
|
||
|
return LottieCompositionFactory.fromJsonInputStreamSync(inputStream, null).getValue();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromJsonSync(Resources resources, JSONObject jSONObject) {
|
||
|
return LottieCompositionFactory.fromJsonSync(jSONObject, null).getValue();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromJsonSync(String str) {
|
||
|
return LottieCompositionFactory.fromJsonStringSync(str, null).getValue();
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static LottieComposition fromJsonSync(JsonReader jsonReader) {
|
||
|
return LottieCompositionFactory.fromJsonReaderSync(jsonReader, null).getValue();
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class ListenerAdapter implements LottieListener<LottieComposition>, Cancellable {
|
||
|
private boolean cancelled;
|
||
|
private final OnCompositionLoadedListener listener;
|
||
|
|
||
|
private ListenerAdapter(OnCompositionLoadedListener onCompositionLoadedListener) {
|
||
|
this.cancelled = false;
|
||
|
this.listener = onCompositionLoadedListener;
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.LottieListener
|
||
|
public final void onResult(LottieComposition lottieComposition) {
|
||
|
if (this.cancelled) {
|
||
|
return;
|
||
|
}
|
||
|
this.listener.onCompositionLoaded(lottieComposition);
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.Cancellable
|
||
|
public final void cancel() {
|
||
|
this.cancelled = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Layer layerModelForId(long j) {
|
||
|
return this.layerMap.c(j);
|
||
|
}
|
||
|
|
||
|
public void setHasDashPattern(boolean z) {
|
||
|
this.hasDashPattern = z;
|
||
|
}
|
||
|
|
||
|
public void init(Rect rect, float f, float f2, float f3, List<Layer> list, C0667Ltg<Layer> c0667Ltg, Map<String, List<Layer>> map, Map<String, LottieImageAsset> map2, VOL<FontCharacter> vol, Map<String, Font> map3, List<Marker> list2) {
|
||
|
this.bounds = rect;
|
||
|
this.startFrame = f;
|
||
|
this.endFrame = f2;
|
||
|
this.frameRate = f3;
|
||
|
this.layers = list;
|
||
|
this.layerMap = c0667Ltg;
|
||
|
this.precomps = map;
|
||
|
this.images = map2;
|
||
|
this.characters = vol;
|
||
|
this.fonts = map3;
|
||
|
this.markers = list2;
|
||
|
}
|
||
|
|
||
|
public void incrementMatteOrMaskCount(int i) {
|
||
|
this.maskAndMatteCount += i;
|
||
|
}
|
||
|
|
||
|
public boolean hasDashPattern() {
|
||
|
return this.hasDashPattern;
|
||
|
}
|
||
|
|
||
|
public float getStartFrame() {
|
||
|
return this.startFrame;
|
||
|
}
|
||
|
|
||
|
public float getProgressForFrame(float f) {
|
||
|
float f2 = this.startFrame;
|
||
|
return (f - f2) / (this.endFrame - f2);
|
||
|
}
|
||
|
|
||
|
public PerformanceTracker getPerformanceTracker() {
|
||
|
return this.performanceTracker;
|
||
|
}
|
||
|
|
||
|
public int getMaskAndMatteCount() {
|
||
|
return this.maskAndMatteCount;
|
||
|
}
|
||
|
|
||
|
public List<Marker> getMarkers() {
|
||
|
return this.markers;
|
||
|
}
|
||
|
|
||
|
public List<Layer> getLayers() {
|
||
|
return this.layers;
|
||
|
}
|
||
|
|
||
|
public Map<String, LottieImageAsset> getImages() {
|
||
|
return this.images;
|
||
|
}
|
||
|
|
||
|
public float getFrameRate() {
|
||
|
return this.frameRate;
|
||
|
}
|
||
|
|
||
|
public Map<String, Font> getFonts() {
|
||
|
return this.fonts;
|
||
|
}
|
||
|
|
||
|
public float getEndFrame() {
|
||
|
return this.endFrame;
|
||
|
}
|
||
|
|
||
|
public float getDurationFrames() {
|
||
|
return this.endFrame - this.startFrame;
|
||
|
}
|
||
|
|
||
|
public VOL<FontCharacter> getCharacters() {
|
||
|
return this.characters;
|
||
|
}
|
||
|
|
||
|
public Rect getBounds() {
|
||
|
return this.bounds;
|
||
|
}
|
||
|
}
|