use of com.airbnb.lottie.model.animatable.AnimatableFloatValue in project lottie-android by airbnb.
the class RepeaterParser method parse.
static Repeater parse(JsonReader reader, LottieComposition composition) throws IOException {
String name = null;
AnimatableFloatValue copies = null;
AnimatableFloatValue offset = null;
AnimatableTransform transform = null;
boolean hidden = false;
while (reader.hasNext()) {
switch(reader.selectName(NAMES)) {
case 0:
name = reader.nextString();
break;
case 1:
copies = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 2:
offset = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 3:
transform = AnimatableTransformParser.parse(reader, composition);
break;
case 4:
hidden = reader.nextBoolean();
break;
default:
reader.skipValue();
}
}
return new Repeater(name, copies, offset, transform, hidden);
}
use of com.airbnb.lottie.model.animatable.AnimatableFloatValue in project lottie-android by airbnb.
the class AnimatablePathValueParser method parseSplitPath.
/**
* Returns either an {@link AnimatablePathValue} or an {@link AnimatableSplitDimensionPathValue}.
*/
static AnimatableValue<PointF, PointF> parseSplitPath(JsonReader reader, LottieComposition composition) throws IOException {
AnimatablePathValue pathAnimation = null;
AnimatableFloatValue xAnimation = null;
AnimatableFloatValue yAnimation = null;
boolean hasExpressions = false;
reader.beginObject();
while (reader.peek() != JsonReader.Token.END_OBJECT) {
switch(reader.selectName(NAMES)) {
case 0:
pathAnimation = AnimatablePathValueParser.parse(reader, composition);
break;
case 1:
if (reader.peek() == JsonReader.Token.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
xAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
case 2:
if (reader.peek() == JsonReader.Token.STRING) {
hasExpressions = true;
reader.skipValue();
} else {
yAnimation = AnimatableValueParser.parseFloat(reader, composition);
}
break;
default:
reader.skipName();
reader.skipValue();
}
}
reader.endObject();
if (hasExpressions) {
composition.addWarning("Lottie doesn't support expressions.");
}
if (pathAnimation != null) {
return pathAnimation;
}
return new AnimatableSplitDimensionPathValue(xAnimation, yAnimation);
}
use of com.airbnb.lottie.model.animatable.AnimatableFloatValue in project lottie-android by airbnb.
the class AnimatableTransformParser method parse.
public static AnimatableTransform parse(JsonReader reader, LottieComposition composition) throws IOException {
AnimatablePathValue anchorPoint = null;
AnimatableValue<PointF, PointF> position = null;
AnimatableScaleValue scale = null;
AnimatableFloatValue rotation = null;
AnimatableIntegerValue opacity = null;
AnimatableFloatValue startOpacity = null;
AnimatableFloatValue endOpacity = null;
AnimatableFloatValue skew = null;
AnimatableFloatValue skewAngle = null;
boolean isObject = reader.peek() == JsonReader.Token.BEGIN_OBJECT;
if (isObject) {
reader.beginObject();
}
while (reader.hasNext()) {
switch(reader.selectName(NAMES)) {
case // a
0:
reader.beginObject();
while (reader.hasNext()) {
switch(reader.selectName(ANIMATABLE_NAMES)) {
case 0:
anchorPoint = AnimatablePathValueParser.parse(reader, composition);
break;
default:
reader.skipName();
reader.skipValue();
}
}
reader.endObject();
break;
case // p
1:
position = AnimatablePathValueParser.parseSplitPath(reader, composition);
break;
case // s
2:
scale = AnimatableValueParser.parseScale(reader, composition);
break;
case // rz
3:
composition.addWarning("Lottie doesn't support 3D layers.");
case // r
4:
/*
* Sometimes split path rotation gets exported like:
* "rz": {
* "a": 1,
* "k": [
* {}
* ]
* },
* which doesn't parse to a real keyframe.
*/
rotation = AnimatableValueParser.parseFloat(reader, composition, false);
if (rotation.getKeyframes().isEmpty()) {
rotation.getKeyframes().add(new Keyframe<>(composition, 0f, 0f, null, 0f, composition.getEndFrame()));
} else if (rotation.getKeyframes().get(0).startValue == null) {
rotation.getKeyframes().set(0, new Keyframe<>(composition, 0f, 0f, null, 0f, composition.getEndFrame()));
}
break;
case // o
5:
opacity = AnimatableValueParser.parseInteger(reader, composition);
break;
case // so
6:
startOpacity = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case // eo
7:
endOpacity = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case // sk
8:
skew = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case // sa
9:
skewAngle = AnimatableValueParser.parseFloat(reader, composition, false);
break;
default:
reader.skipName();
reader.skipValue();
}
}
if (isObject) {
reader.endObject();
}
if (isAnchorPointIdentity(anchorPoint)) {
anchorPoint = null;
}
if (isPositionIdentity(position)) {
position = null;
}
if (isRotationIdentity(rotation)) {
rotation = null;
}
if (isScaleIdentity(scale)) {
scale = null;
}
if (isSkewIdentity(skew)) {
skew = null;
}
if (isSkewAngleIdentity(skewAngle)) {
skewAngle = null;
}
return new AnimatableTransform(anchorPoint, position, scale, rotation, opacity, startOpacity, endOpacity, skew, skewAngle);
}
use of com.airbnb.lottie.model.animatable.AnimatableFloatValue in project lottie-android by airbnb.
the class RectangleShapeParser method parse.
static RectangleShape parse(JsonReader reader, LottieComposition composition) throws IOException {
String name = null;
AnimatableValue<PointF, PointF> position = null;
AnimatableValue<PointF, PointF> size = null;
AnimatableFloatValue roundedness = null;
boolean hidden = false;
while (reader.hasNext()) {
switch(reader.selectName(NAMES)) {
case 0:
name = reader.nextString();
break;
case 1:
position = AnimatablePathValueParser.parseSplitPath(reader, composition);
break;
case 2:
size = AnimatableValueParser.parsePoint(reader, composition);
break;
case 3:
roundedness = AnimatableValueParser.parseFloat(reader, composition);
break;
case 4:
hidden = reader.nextBoolean();
break;
default:
reader.skipValue();
}
}
return new RectangleShape(name, position, size, roundedness, hidden);
}
use of com.airbnb.lottie.model.animatable.AnimatableFloatValue in project lottie-android by airbnb.
the class PolystarShapeParser method parse.
static PolystarShape parse(JsonReader reader, LottieComposition composition, int d) throws IOException {
String name = null;
PolystarShape.Type type = null;
AnimatableFloatValue points = null;
AnimatableValue<PointF, PointF> position = null;
AnimatableFloatValue rotation = null;
AnimatableFloatValue outerRadius = null;
AnimatableFloatValue outerRoundedness = null;
AnimatableFloatValue innerRadius = null;
AnimatableFloatValue innerRoundedness = null;
boolean hidden = false;
boolean reversed = d == 3;
while (reader.hasNext()) {
switch(reader.selectName(NAMES)) {
case 0:
name = reader.nextString();
break;
case 1:
type = PolystarShape.Type.forValue(reader.nextInt());
break;
case 2:
points = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 3:
position = AnimatablePathValueParser.parseSplitPath(reader, composition);
break;
case 4:
rotation = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 5:
outerRadius = AnimatableValueParser.parseFloat(reader, composition);
break;
case 6:
outerRoundedness = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 7:
innerRadius = AnimatableValueParser.parseFloat(reader, composition);
break;
case 8:
innerRoundedness = AnimatableValueParser.parseFloat(reader, composition, false);
break;
case 9:
hidden = reader.nextBoolean();
break;
case 10:
// "d" is 2 for normal and 3 for reversed.
reversed = reader.nextInt() == 3;
break;
default:
reader.skipName();
reader.skipValue();
}
}
return new PolystarShape(name, type, points, position, rotation, innerRadius, outerRadius, innerRoundedness, outerRoundedness, hidden, reversed);
}
Aggregations