74 lines
3.4 KiB
Java
74 lines
3.4 KiB
Java
|
package com.airbnb.lottie.animation.content;
|
||
|
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.ColorFilter;
|
||
|
import android.graphics.Matrix;
|
||
|
import com.airbnb.lottie.LottieDrawable;
|
||
|
import com.airbnb.lottie.LottieProperty;
|
||
|
import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
|
||
|
import com.airbnb.lottie.animation.keyframe.ColorKeyframeAnimation;
|
||
|
import com.airbnb.lottie.animation.keyframe.ValueCallbackKeyframeAnimation;
|
||
|
import com.airbnb.lottie.model.content.ShapeStroke;
|
||
|
import com.airbnb.lottie.model.layer.BaseLayer;
|
||
|
import com.airbnb.lottie.value.LottieValueCallback;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public class StrokeContent extends BaseStrokeContent {
|
||
|
private final BaseKeyframeAnimation<Integer, Integer> colorAnimation;
|
||
|
private BaseKeyframeAnimation<ColorFilter, ColorFilter> colorFilterAnimation;
|
||
|
private final boolean hidden;
|
||
|
private final BaseLayer layer;
|
||
|
private final String name;
|
||
|
|
||
|
public StrokeContent(LottieDrawable lottieDrawable, BaseLayer baseLayer, ShapeStroke shapeStroke) {
|
||
|
super(lottieDrawable, baseLayer, shapeStroke.getCapType().toPaintCap(), shapeStroke.getJoinType().toPaintJoin(), shapeStroke.getMiterLimit(), shapeStroke.getOpacity(), shapeStroke.getWidth(), shapeStroke.getLineDashPattern(), shapeStroke.getDashOffset());
|
||
|
this.layer = baseLayer;
|
||
|
this.name = shapeStroke.getName();
|
||
|
this.hidden = shapeStroke.isHidden();
|
||
|
BaseKeyframeAnimation<Integer, Integer> createAnimation = shapeStroke.getColor().createAnimation();
|
||
|
this.colorAnimation = createAnimation;
|
||
|
createAnimation.addUpdateListener(this);
|
||
|
baseLayer.addAnimation(createAnimation);
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.animation.content.BaseStrokeContent, com.airbnb.lottie.animation.content.DrawingContent
|
||
|
public void draw(Canvas canvas, Matrix matrix, int i) {
|
||
|
if (this.hidden) {
|
||
|
return;
|
||
|
}
|
||
|
this.paint.setColor(((ColorKeyframeAnimation) this.colorAnimation).getIntValue());
|
||
|
if (this.colorFilterAnimation != null) {
|
||
|
this.paint.setColorFilter(this.colorFilterAnimation.getValue());
|
||
|
}
|
||
|
super.draw(canvas, matrix, i);
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.animation.content.BaseStrokeContent, com.airbnb.lottie.model.KeyPathElement
|
||
|
public <T> void addValueCallback(T t, LottieValueCallback<T> lottieValueCallback) {
|
||
|
super.addValueCallback(t, lottieValueCallback);
|
||
|
if (t == LottieProperty.STROKE_COLOR) {
|
||
|
this.colorAnimation.setValueCallback(lottieValueCallback);
|
||
|
return;
|
||
|
}
|
||
|
if (t == LottieProperty.COLOR_FILTER) {
|
||
|
BaseKeyframeAnimation<ColorFilter, ColorFilter> baseKeyframeAnimation = this.colorFilterAnimation;
|
||
|
if (baseKeyframeAnimation != null) {
|
||
|
this.layer.removeAnimation(baseKeyframeAnimation);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.colorFilterAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.colorFilterAnimation = valueCallbackKeyframeAnimation;
|
||
|
valueCallbackKeyframeAnimation.addUpdateListener(this);
|
||
|
this.layer.addAnimation(this.colorAnimation);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.animation.content.Content
|
||
|
public String getName() {
|
||
|
return this.name;
|
||
|
}
|
||
|
}
|