blob: 7580410a5894b2c00831a1f2a3bb26b0d1a436e4 [file] [log] [blame]
package com.airbnb.lottie;
import android.graphics.Path;
import org.json.JSONObject;
import java.util.List;
class AnimatableShapeValue extends BaseAnimatableValue<ShapeData, Path> {
private final Path convertTypePath = new Path();
private AnimatableShapeValue(List<Keyframe<ShapeData>> keyframes, LottieComposition composition,
ShapeData initialValue) {
super(keyframes, composition, initialValue);
}
@Override public BaseKeyframeAnimation<?, Path> createAnimation() {
if (!hasAnimation()) {
return new StaticKeyframeAnimation<>(convertType(initialValue));
} else {
return new ShapeKeyframeAnimation(keyframes);
}
}
@Override Path convertType(ShapeData shapeData) {
convertTypePath.reset();
MiscUtils.getPathFromData(shapeData, convertTypePath);
return convertTypePath;
}
static final class Factory {
private Factory() {
}
static AnimatableShapeValue newInstance(JSONObject json, LottieComposition composition) {
AnimatableValueParser.Result<ShapeData> result = AnimatableValueParser
.newInstance(json, composition.getScale(), composition, ShapeData.Factory.INSTANCE)
.parseJson();
return new AnimatableShapeValue(result.keyframes, composition, result.initialValue);
}
}
}