what-the-bank/sources/com/airbnb/lottie/animation/content/ShapeContent.java

92 lines
3.3 KiB
Java

package com.airbnb.lottie.animation.content;
import android.graphics.Path;
import com.airbnb.lottie.LottieDrawable;
import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
import com.airbnb.lottie.animation.keyframe.ShapeKeyframeAnimation;
import com.airbnb.lottie.model.content.ShapePath;
import com.airbnb.lottie.model.content.ShapeTrimPath;
import com.airbnb.lottie.model.layer.BaseLayer;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public class ShapeContent implements PathContent, BaseKeyframeAnimation.AnimationListener {
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();
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) {
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.animation.content.Content
public String getName() {
return this.name;
}
}