Rabbit-R1/android (non root)/java/sources/com/airbnb/lottie/animation/content/ShapeContent.java

108 lines
4 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package com.airbnb.lottie.animation.content;
import android.graphics.Path;
import com.airbnb.lottie.LottieDrawable;
import com.airbnb.lottie.LottieProperty;
import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
import com.airbnb.lottie.animation.keyframe.ShapeKeyframeAnimation;
import com.airbnb.lottie.model.KeyPath;
import com.airbnb.lottie.model.content.ShapePath;
import com.airbnb.lottie.model.content.ShapeTrimPath;
import com.airbnb.lottie.model.layer.BaseLayer;
import com.airbnb.lottie.utils.MiscUtils;
import com.airbnb.lottie.value.LottieValueCallback;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes2.dex */
public class ShapeContent implements PathContent, BaseKeyframeAnimation.AnimationListener, KeyPathElementContent {
private final boolean hidden;
private boolean isPathValid;
private final LottieDrawable lottieDrawable;
private final String name;
private final ShapeKeyframeAnimation shapeAnimation;
private List<ShapeModifierContent> shapeModifierContents;
private final Path path = new Path();
private final CompoundTrimPathContent trimPaths = new CompoundTrimPathContent();
@Override // com.airbnb.lottie.animation.content.Content
public String getName() {
return this.name;
}
public ShapeContent(LottieDrawable lottieDrawable, BaseLayer baseLayer, ShapePath shapePath) {
this.name = shapePath.getName();
this.hidden = shapePath.isHidden();
this.lottieDrawable = lottieDrawable;
ShapeKeyframeAnimation createAnimation = shapePath.getShapePath().createAnimation();
this.shapeAnimation = createAnimation;
baseLayer.addAnimation(createAnimation);
createAnimation.addUpdateListener(this);
}
@Override // com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation.AnimationListener
public void onValueChanged() {
invalidate();
}
private void invalidate() {
this.isPathValid = false;
this.lottieDrawable.invalidateSelf();
}
@Override // com.airbnb.lottie.animation.content.Content
public void setContents(List<Content> list, List<Content> list2) {
ArrayList arrayList = null;
for (int i = 0; i < list.size(); i++) {
Content content = list.get(i);
if (content instanceof TrimPathContent) {
TrimPathContent trimPathContent = (TrimPathContent) content;
if (trimPathContent.getType() == ShapeTrimPath.Type.SIMULTANEOUSLY) {
this.trimPaths.addTrimPath(trimPathContent);
trimPathContent.addListener(this);
}
}
if (content instanceof ShapeModifierContent) {
if (arrayList == null) {
arrayList = new ArrayList();
}
arrayList.add((ShapeModifierContent) content);
}
}
this.shapeAnimation.setShapeModifiers(arrayList);
}
@Override // com.airbnb.lottie.animation.content.PathContent
public Path getPath() {
if (this.isPathValid && !this.shapeAnimation.hasValueCallback()) {
return this.path;
}
this.path.reset();
if (this.hidden) {
this.isPathValid = true;
return this.path;
}
Path value = this.shapeAnimation.getValue();
if (value == null) {
return this.path;
}
this.path.set(value);
this.path.setFillType(Path.FillType.EVEN_ODD);
this.trimPaths.apply(this.path);
this.isPathValid = true;
return this.path;
}
@Override // com.airbnb.lottie.model.KeyPathElement
public void resolveKeyPath(KeyPath keyPath, int i, List<KeyPath> list, KeyPath keyPath2) {
MiscUtils.resolveKeyPath(keyPath, i, list, keyPath2, this);
}
@Override // com.airbnb.lottie.model.KeyPathElement
public <T> void addValueCallback(T t, LottieValueCallback<T> lottieValueCallback) {
if (t == LottieProperty.PATH) {
this.shapeAnimation.setValueCallback(lottieValueCallback);
}
}
}